Various tooling improvements from other plugins (#96)
This commit is contained in:
parent
c557d38b4d
commit
a49d6f6dd4
14 changed files with 693 additions and 201 deletions
|
@ -1,4 +1,38 @@
|
|||
var path = require('path');
|
||||
const exec = require('child_process').exec;
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const PLUGIN_ID = require('../plugin.json').id;
|
||||
|
||||
const NPM_TARGET = process.env.npm_lifecycle_event; //eslint-disable-line no-process-env
|
||||
let mode = 'production';
|
||||
let devtool = '';
|
||||
if (NPM_TARGET === 'debug' || NPM_TARGET === 'debug:watch') {
|
||||
mode = 'development';
|
||||
devtool = 'source-map';
|
||||
}
|
||||
|
||||
const plugins = [];
|
||||
if (NPM_TARGET === 'build:watch' || NPM_TARGET === 'debug:watch') {
|
||||
plugins.push({
|
||||
apply: (compiler) => {
|
||||
compiler.hooks.watchRun.tap('WatchStartPlugin', () => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Change detected. Rebuilding webapp.');
|
||||
});
|
||||
compiler.hooks.afterEmit.tap('AfterEmitPlugin', () => {
|
||||
exec('cd .. && make deploy-from-watch', (err, stdout, stderr) => {
|
||||
if (stdout) {
|
||||
process.stdout.write(stdout);
|
||||
}
|
||||
if (stderr) {
|
||||
process.stderr.write(stderr);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: [
|
||||
|
@ -25,6 +59,21 @@ module.exports = {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.scss$/,
|
||||
use: [
|
||||
'style-loader',
|
||||
{
|
||||
loader: 'css-loader',
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
includePaths: ['node_modules/compass-mixins/lib', 'sass'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
externals: {
|
||||
|
@ -36,8 +85,12 @@ module.exports = {
|
|||
'react-router-dom': 'ReactRouterDom',
|
||||
},
|
||||
output: {
|
||||
devtoolNamespace: PLUGIN_ID,
|
||||
path: path.join(__dirname, '/dist'),
|
||||
publicPath: '/',
|
||||
filename: 'main.js',
|
||||
},
|
||||
devtool,
|
||||
mode,
|
||||
plugins,
|
||||
};
|
||||
|
|
Reference in a new issue