PODEntender /
estatista
| 1 | let argv = require('yargs').argv; |
||
| 2 | let bin = require('./bin'); |
||
| 3 | let command = require('node-cmd'); |
||
| 4 | |||
| 5 | let BrowserSync = require('browser-sync'); |
||
| 6 | let BrowserSyncPlugin = require('browser-sync-webpack-plugin'); |
||
| 7 | let ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin'); |
||
| 8 | |||
| 9 | let browserSyncInstance; |
||
| 10 | let env = argv.e || argv.env || 'local'; |
||
| 11 | let port = argv.p || argv.port || 3000; |
||
| 12 | |||
| 13 | module.exports = { |
||
| 14 | jigsaw: { |
||
| 15 | apply(compiler) { |
||
| 16 | compiler.hooks.done.tap('DonePlugin', (compilation) => { |
||
| 17 | command.get(bin.path() + ' build -q ' + env, (error, stdout, stderr) => { |
||
| 18 | console.log(error ? stderr : stdout); |
||
|
0 ignored issues
–
show
Debugging Code
introduced
by
Loading history...
|
|||
| 19 | |||
| 20 | if (browserSyncInstance) { |
||
| 21 | browserSyncInstance.reload(); |
||
| 22 | } |
||
| 23 | }); |
||
| 24 | }); |
||
| 25 | } |
||
| 26 | }, |
||
| 27 | |||
| 28 | watch: function (paths) { |
||
| 29 | return new ExtraWatchWebpackPlugin({ |
||
| 30 | files: paths, |
||
| 31 | }); |
||
| 32 | }, |
||
| 33 | |||
| 34 | browserSync: function (proxy) { |
||
| 35 | return new BrowserSyncPlugin({ |
||
| 36 | notify: false, |
||
| 37 | port: port, |
||
| 38 | proxy: proxy, |
||
| 39 | server: proxy ? null : { baseDir: 'build_' + env + '/' }, |
||
| 40 | }, |
||
| 41 | { |
||
| 42 | reload: false, |
||
| 43 | callback: function() { |
||
| 44 | browserSyncInstance = BrowserSync.get('bs-webpack-plugin'); |
||
| 45 | }, |
||
| 46 | }) |
||
| 47 | }, |
||
| 48 | }; |
||
| 49 |