Skip to content
Snippets Groups Projects
Verified Commit 3052a60d authored by David Beniamine's avatar David Beniamine
Browse files

WIP cleaner build using webpack hooks

parent b3daef7f
No related branches found
No related tags found
No related merge requests found
...@@ -5,4 +5,4 @@ RUN chown node:node /opt ...@@ -5,4 +5,4 @@ RUN chown node:node /opt
EXPOSE 9000 EXPOSE 9000
WORKDIR /opt WORKDIR /opt
USER node USER node
CMD npm install && npm run serve CMD npm run serve
#!/bin/bash
declare -A SUBMODULES=(
['mirador-video-annotation']="build:es"
['annotations-plugin']="build"
)
run_on_modules(){
for mod in "${!SUBMODULES[@]}"; do
echo -e "\t$mod"
cd $mod
npm run ${SUBMODULES[${mod}]}
cd ..
done
}
npm install
echo "Compiling submodules"
run_on_modules build
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
"devDependencies": { "devDependencies": {
"webpack": "^4.43.0", "webpack": "^4.43.0",
"webpack-cli": "^4.3.12", "webpack-cli": "^4.3.12",
"webpack-dev-server": "^4.11.1", "webpack-dev-server": "^4.11.1"
"webpack-shell-plugin": "^0.5.0"
} }
}, },
"annotations-plugin": { "annotations-plugin": {
...@@ -24917,12 +24916,6 @@ ...@@ -24917,12 +24916,6 @@
"node": ">=10.0.0" "node": ">=10.0.0"
} }
}, },
"node_modules/webpack-shell-plugin": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/webpack-shell-plugin/-/webpack-shell-plugin-0.5.0.tgz",
"integrity": "sha512-BJMcVgXzA7Yc/Dq9JFj/wvquYG5qP3lgmCpMYzhP1a+LxZ/z3TbqKJ3W2xTkzQqBeYsgTdOcSdZ/+qYoFBhMhA==",
"dev": true
},
"node_modules/webpack-sources": { "node_modules/webpack-sources": {
"version": "1.4.3", "version": "1.4.3",
"license": "MIT", "license": "MIT",
...@@ -42380,12 +42373,6 @@ ...@@ -42380,12 +42373,6 @@
"wildcard": "^2.0.0" "wildcard": "^2.0.0"
} }
}, },
"webpack-shell-plugin": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/webpack-shell-plugin/-/webpack-shell-plugin-0.5.0.tgz",
"integrity": "sha512-BJMcVgXzA7Yc/Dq9JFj/wvquYG5qP3lgmCpMYzhP1a+LxZ/z3TbqKJ3W2xTkzQqBeYsgTdOcSdZ/+qYoFBhMhA==",
"dev": true
},
"webpack-sources": { "webpack-sources": {
"version": "1.4.3", "version": "1.4.3",
"requires": { "requires": {
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
"private": true, "private": true,
"scripts": { "scripts": {
"build": "webpack --config webpack.config.js", "build": "webpack --config webpack.config.js",
"preserve": "npm run build",
"serve": "webpack serve --config webpack.config.js" "serve": "webpack serve --config webpack.config.js"
}, },
"author": "", "author": "",
...@@ -24,7 +23,6 @@ ...@@ -24,7 +23,6 @@
"devDependencies": { "devDependencies": {
"webpack": "^4.43.0", "webpack": "^4.43.0",
"webpack-cli": "^4.3.12", "webpack-cli": "^4.3.12",
"webpack-dev-server": "^4.11.1", "webpack-dev-server": "^4.11.1"
"webpack-shell-plugin": "^0.5.0"
} }
} }
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const Dotenv = require('dotenv-webpack'); const Dotenv = require('dotenv-webpack');
const WebpackShellPlugin = require('webpack-shell-plugin'); const child_process = require('child_process');
module.exports = { module.exports = {
mode: process.env.WEBPACK_MODE, mode: process.env.WEBPACK_MODE,
...@@ -13,8 +13,7 @@ module.exports = { ...@@ -13,8 +13,7 @@ module.exports = {
}, },
devServer: { devServer: {
hot: true, hot: true,
liveReload: true, watchFiles: ['src/**/*.js'],
watchFiles: ['src/**/*', '*/src/**/*'],
client: { client: {
logging: 'verbose', logging: 'verbose',
overlay: true, overlay: true,
...@@ -39,9 +38,30 @@ module.exports = { ...@@ -39,9 +38,30 @@ module.exports = {
/* cf https://gitlab.tetras-libre.fr/iiif/mirador-video-annotation/-/blob/annotation-on-video/webpack.config.js#L42 */ /* cf https://gitlab.tetras-libre.fr/iiif/mirador-video-annotation/-/blob/annotation-on-video/webpack.config.js#L42 */
resourceRegExp: /@blueprintjs\/(core|icons)/, // ignore optional UI framework dependencies resourceRegExp: /@blueprintjs\/(core|icons)/, // ignore optional UI framework dependencies
}), }),
new WebpackShellPlugin({ {
onBuildStart:['./build_deps.sh'] apply: (compiler) => {
}), function spawn(cmd, args, cwd) {
let ret = child_process.spawnSync(cmd, args, {cwd: path.resolve(cwd)});
if (ret.output) {
console.log(ret.output.toString());
}
if (ret.status !== 0) {
throw Error('Error while running ""'+cmd+' '+args);
}
}
// TODO this hook runs again and again in watch mode, use something more restrictive
compiler.hooks.compile.tap("compile workspaces", () => {
console.log('Compiling workspaces');
console.log('annotations plugin');
// TODO Use values from package.json
spawn("rm", ["-f", ".babelrc"], 'annotations-plugin');
spawn("npm", ["run", "build"], 'annotations-plugin');
console.log('mirador');
spawn("npm", ["run", "build:es"], 'mirador-video-annotation');
console.log('Workspaces compiled successfully');
});
}
},
new Dotenv() new Dotenv()
] ]
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment