Skip to content

Commit

Permalink
Merge pull request #6 from VCityTeam/dev
Browse files Browse the repository at this point in the history
folder and port can be pass as arguments + travis test
  • Loading branch information
EricBoix authored Mar 22, 2021
2 parents 7c43308 + bc0070b commit 048eb8a
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 29 deletions.
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# @format

os: linux
dist: focal
language: node_js
node_js:
- 14

jobs:
include:
- stage: DemoFull
script:
- cd DemoFull && npm install && npm build
- stage: Imuv
script:
- cd Imuv && npm install && npm build
- stage: ImuvEditor
script:
- cd ImuvEditor && npm install && npm build
- stage: ImuvServer
script:
- cd ImuvServer && npm install && npm build
- stage: SimpleServer
script:
- cd SimpleServer && npm install && npm build
2 changes: 1 addition & 1 deletion DemoFull/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"author": "",
"license": "ISC",
"dependencies": {
"three": "^0.125.2",
"@egjs/hammerjs": "^2.0.17",
"jquery": "^1.0.0",
"keycharm": "^0.4.0",
"proj4": "^2.7.0",
"three": "0.125.2",
"timsort": "^0.3.0",
"ud-viz": "^2.31.0",
"uuid": "^8.3.2",
Expand Down
26 changes: 15 additions & 11 deletions DemoFull/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ const debugBuild = mode === 'development';
const HtmlWebpackPlugin = require('html-webpack-plugin');

let outputPath;
let devTool;
if (debugBuild) {
devTool = 'source-map';
outputPath = path.resolve(__dirname, 'dist/debug');
} else {
devTool = 'none';
outputPath = path.resolve(__dirname, 'dist/release');
}

Expand All @@ -37,10 +34,18 @@ module.exports = (env) => {
},
];

return {
const plugins = [];
if (debugBuild)
plugins.push(
new HtmlWebpackPlugin({
title: 'Demo debug',
filename: 'index.html',
})
);

const config = {
mode,
entry: [path.resolve(__dirname, './src/bootstrap.js')],
devtool: devTool,
output: {
path: outputPath,
filename: 'app_name.js',
Expand All @@ -55,11 +60,10 @@ module.exports = (env) => {
port: 8000,
hot: true,
},
plugins: [
new HtmlWebpackPlugin({
title: 'Demo debug',
filename: 'index.html',
}),
],
plugins: plugins,
};

if (debugBuild) config.devtool = 'source-map';

return config;
};
16 changes: 10 additions & 6 deletions ImuvEditor/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ module.exports = (env) => {
},
];

const plugins = [];
if (debugBuild)
plugins.push(
new HtmlWebpackPlugin({
title: 'Demo debug',
filename: 'index.html',
})
);

return {
mode,
entry: [path.resolve(__dirname, './src/bootstrap.js')],
Expand All @@ -55,11 +64,6 @@ module.exports = (env) => {
port: 8000,
hot: true,
},
plugins: [
new HtmlWebpackPlugin({
title: 'Demo debug',
filename: 'index.html',
}),
],
plugins: plugins,
};
};
4 changes: 0 additions & 4 deletions SimpleServer/assets/config/config.json

This file was deleted.

2 changes: 1 addition & 1 deletion SimpleServer/bin/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exec('npm run build-debug')
.then(printExec)
.then(function () {
console.log('Launch bundle\n');
var child = spawn('node', ['./index.js']);
var child = spawn('node', ['./index.js', '../DemoFull', '8000']);
child.stdout.on('data', (data) => {
console.log(`child stdout:\n${data}`);
});
Expand Down
8 changes: 5 additions & 3 deletions SimpleServer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

try {
const bundle = require('./dist/server.js');
const config = require('./assets/config/config.json');

//instanciate server
const server = new bundle.SimpleServer();

//start server
server.start(config);

//node command should be like 'node index.js ../DemoFull 8000'
const folder = process.argv[2];
const port = process.argv[3];
server.start({ folder: folder, port: port });

} catch (e) {
console.error(e);
}
5 changes: 2 additions & 3 deletions SimpleServer/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ export class SimpleServer {
app.use(express.static(config.folder)); //what folder is served

//http server
const port = config.port;
app.listen(port, function (err) {
app.listen(config.port, function (err) {
if (err) console.log('Error in server setup');
console.log('Server listening on Port', port, ' folder ' + config.folder);
console.log('Server listening on Port', config.port, ' folder ' + config.folder);
});
}
}

0 comments on commit 048eb8a

Please sign in to comment.