forked from didi/cube-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.modules.conf.js
45 lines (42 loc) · 1.14 KB
/
webpack.modules.conf.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
36
37
38
39
40
41
42
43
44
45
var path = require('path')
var fs = require('fs')
var config = require('../config')
var utils = require('./utils')
var webpack = require('webpack')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var modules = {}
var cPath = path.join(__dirname, '../src/modules')
var files = fs.readdirSync(cPath)
if (files) {
files.forEach(function (name) {
var p = path.join(cPath, name)
if (fs.statSync(p).isDirectory()) {
modules[name] = p
}
})
}
var webpackConfig = merge(baseWebpackConfig, {
entry: modules,
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: {
publicPath: '../'
}
})
},
devtool: config.build.productionSourceMap ? '#source-map' : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('[name]/index.js'),
library: ['cube', '[name]'],
libraryTarget: 'umd'
},
plugins: [
// extract css into its own file
new ExtractTextPlugin(utils.assetsPath('[name]/style.css'))
]
})
module.exports = webpackConfig