-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
53 lines (49 loc) · 1.35 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
const webpack = require('webpack')
const path = require('path')
const packageJson = require('./package.json')
const HtmlWebpackPlugin = require('html-webpack-plugin')
let config = {
mode: 'production',
entry: {
db: './src/index.js'
},
output: {
filename: '[name].min.js'.toLowerCase(),
path: path.resolve(__dirname, 'dist'),
libraryExport: 'default',
libraryTarget: 'umd',
clean: true
},
plugins: []
}
module.exports = (env, argv) => {
if (argv.mode === 'development') {
config.devtool = 'source-map'
config.output = {
publicPath: '/'
}
config.optimization = {
usedExports: true
}
config.devServer = {
contentBase: [path.join(__dirname, 'dist'), path.join(__dirname, 'assets'), path.join(__dirname, 'playground')],
compress: true,
port: 9000
}
config.module = {
rules: [
{
test: /\.(json)$/,
use: ['file-loader']
}
]
}
}
if (argv.mode === 'production') {
config.plugins.push(new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify('production') } }))
config.plugins.push(
new webpack.BannerPlugin(` ${packageJson.name.toUpperCase()} v-${packageJson.version} \n Author: ${packageJson.author} \n License: ${packageJson.license} \n Homepage: ${packageJson.homepage}`)
)
}
return config
}