-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·74 lines (74 loc) · 2.06 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
70
71
72
73
74
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const merge = require('webpack-merge');
const developmentConfig = require('./webpack.development.config');
const productionConfig = require('./webpack.production.config');
const NODE_ENV = process.env.NODE_ENV;
const devMode = NODE_ENV === 'development';
module.exports = merge(devMode ? developmentConfig : productionConfig, {
entry: {
'y.lottery': './src/main.js'
},
output: {
filename: '[name].min.js',
path: path.resolve(__dirname, 'dist/'),
libraryTarget: 'umd',
// library: ['ylottery']
},
devtool: 'inline-source-map',
module: {
rules: [{
test: /\.(sa|sc|c)ss$/,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
'sass-loader',
]
}, {
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['es2015']
}
}
}]
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: devMode ? '[name].css' : '[name].css',
chunkFilename: devMode ? '[id].css' : '[id].[hash].css',
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV)
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src/')
}
},
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
});