UNPKG

864 BJavaScriptView Raw
1//
2
3
4
5
6
7
8
9const fs = require('fs-extra')
10const { TerminalUtils } = require('constellate-dev-utils')
11const bundle = require('./bundle')
12const develop = require('./develop')
13
14// :: Package, Options -> DevelopAPI
15module.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}