-
Notifications
You must be signed in to change notification settings - Fork 35
/
webpack.config.js
69 lines (65 loc) · 1.43 KB
/
webpack.config.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* eslint-env node */
const webpack = require('webpack')
const { merge } = require('webpack-merge')
const argv = require('yargs').argv
const { version } = require('./package.json')
const commonConfig = {
entry: './src/index.js',
devtool: 'source-map',
mode: 'production',
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['es2015'],
plugins: ['add-module-exports', 'babel-plugin-bulk-import']
}
},
{
test: /\.scss$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1,
minimize: true
}
},
'postcss-loader',
'sass-loader'
]
}
]
},
plugins: [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(version)
}),
new webpack.BannerPlugin('Built @' + new Date().toUTCString())
// new BundleAnalyzerPlugin()
],
optimization: {
minimize: !argv.watch
}
}
const umd = merge(commonConfig, {
output: {
path: `${__dirname}/dist`,
filename: 'index.js',
library: 'danmu.js',
libraryTarget: 'umd'
}
})
const client = merge(commonConfig, {
output: {
path: `${__dirname}/browser`,
filename: 'index.js',
library: 'DanmuJs',
libraryTarget: 'window'
}
})
module.exports = [umd, client]