diff --git a/Dockerfile.devserver b/Dockerfile.devserver index 4f71e92afca24f3796b6f53db297234f02238ffb..a17d73811f111d1c2bb60e0c69eae5ce9df8fe09 100644 --- a/Dockerfile.devserver +++ b/Dockerfile.devserver @@ -5,4 +5,4 @@ RUN chown node:node /opt EXPOSE 9000 WORKDIR /opt USER node -CMD npm install && npm run serve +CMD npm run serve diff --git a/build_deps.sh b/build_deps.sh deleted file mode 100755 index 51a21ad3ba20e0759472cdf554cfbffd1708315b..0000000000000000000000000000000000000000 --- a/build_deps.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/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 diff --git a/package-lock.json b/package-lock.json index d36b3cd41aec9ffffa26ea9ebc5f0dd915477a34..d841e2aa19ae61a6a408c3d98951d62b56e1a873 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,8 +22,7 @@ "devDependencies": { "webpack": "^4.43.0", "webpack-cli": "^4.3.12", - "webpack-dev-server": "^4.11.1", - "webpack-shell-plugin": "^0.5.0" + "webpack-dev-server": "^4.11.1" } }, "annotations-plugin": { @@ -24917,12 +24916,6 @@ "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": { "version": "1.4.3", "license": "MIT", @@ -42380,12 +42373,6 @@ "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": { "version": "1.4.3", "requires": { diff --git a/package.json b/package.json index 95e52a410d5d13e838f21aafa3904f602eedef80..1542dd7b13b4d80a875423ee8dd660a3527df0a8 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "private": true, "scripts": { "build": "webpack --config webpack.config.js", - "preserve": "npm run build", "serve": "webpack serve --config webpack.config.js" }, "author": "", @@ -24,7 +23,6 @@ "devDependencies": { "webpack": "^4.43.0", "webpack-cli": "^4.3.12", - "webpack-dev-server": "^4.11.1", - "webpack-shell-plugin": "^0.5.0" + "webpack-dev-server": "^4.11.1" } } diff --git a/webpack.config.js b/webpack.config.js index c0519efa548d58056a9d9870112f942bf2dcfe6b..9314ee7aafa15763563d7801fd5155fec9b0b7ad 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,7 +1,7 @@ const path = require('path'); const webpack = require('webpack'); const Dotenv = require('dotenv-webpack'); -const WebpackShellPlugin = require('webpack-shell-plugin'); +const child_process = require('child_process'); module.exports = { mode: process.env.WEBPACK_MODE, @@ -13,8 +13,7 @@ module.exports = { }, devServer: { hot: true, - liveReload: true, - watchFiles: ['src/**/*', '*/src/**/*'], + watchFiles: ['src/**/*.js'], client: { logging: 'verbose', overlay: true, @@ -35,13 +34,34 @@ module.exports = { port: 9000 }, plugins: [ - new webpack.IgnorePlugin({ - /* 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 - }), - new WebpackShellPlugin({ - onBuildStart:['./build_deps.sh'] - }), - new Dotenv() + new webpack.IgnorePlugin({ + /* 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 + }), + { + 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() ] };