-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.js
35 lines (34 loc) · 980 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const PostCompilePlugin = require('webpack-post-compile-plugin')
const TransformModulesPlugin = require('webpack-transform-modules-plugin')
module.exports = (api, projectOptions) => {
// handle stylus options import path
const imports = projectOptions.css.loaderOptions.stylus.import
imports.forEach((path, index) => {
imports[index] = api.resolve(path)
})
const cubeUIOpts = projectOptions.pluginOptions && projectOptions.pluginOptions['cube-ui'] || {
postCompile: true
}
if (cubeUIOpts.postCompile) {
// post compile
api.chainWebpack(config => {
const conf = config.toConfig()
config
.plugin('post-compile')
.use(PostCompilePlugin)
})
} else {
api.chainWebpack(config => {
config
.resolve
.alias
.set('cube-ui', 'cube-ui/lib')
})
}
// transfrom modules
api.chainWebpack(config => {
config
.plugin('transform-modules')
.use(TransformModulesPlugin)
})
}