1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | const fs = require('fs-extra')
|
10 | const { TerminalUtils } = require('constellate-dev-utils')
|
11 | const bundle = require('./bundle')
|
12 | const develop = require('./develop')
|
13 |
|
14 |
|
15 | module.exports = function webpackBuildPlugin(
|
16 | pkg ,
|
17 | ) {
|
18 | return {
|
19 | name: 'constellate-plugin-webpack',
|
20 | build: () => bundle(pkg),
|
21 | clean: () =>
|
22 | new Promise(resolve => {
|
23 | if (fs.pathExistsSync(pkg.paths.packageBuildOutput)) {
|
24 | fs.removeSync(pkg.paths.packageBuildOutput)
|
25 | }
|
26 | resolve()
|
27 | }),
|
28 | deploy: () => {
|
29 | TerminalUtils.error('"deploy" not supported by "webpack" plugin')
|
30 | process.exit(1)
|
31 | },
|
32 | develop: watcher => develop(pkg, watcher),
|
33 | }
|
34 | }
|