forked from superman66/wakatime-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
101 lines (99 loc) · 2.56 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlwebpackPlugin = require('html-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const { NODE_ENV, STYLE_DEBUG, ENV_LOCALE } = process.env;
const __PRO__ = NODE_ENV === 'production';
const extractLess = new ExtractTextPlugin('style.[hash].css');
const rsuiteStylePath = path.resolve(__dirname, './node_modules/rsuite/styles');
module.exports = {
devServer: {
contentBase: path.join(__dirname, 'public'),
disableHostCheck: true,
historyApiFallback: true,
compress: true,
host: '0.0.0.0',
port: 3900
},
entry: {
app: './src/index.js'
},
output: {
filename: '[name].[hash].bundle.js',
path: path.resolve(__dirname, 'dist'),
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
name: 'commons',
chunks: 'initial',
minChunks: 2
}
}
}
},
module: {
rules: [
{
test: /\.js$/,
use: [
//'transform-loader?brfs', // Use browserify transforms as webpack-loader.
'babel-loader?babelrc'
],
exclude: /node_modules/
},
{
test: /\.(less|css)$/,
loader: extractLess.extract({
use: ['css-loader', 'less-loader'],
// use style-loader in development
fallback: 'style-loader?{attrs:{prop: "value"}}'
})
},
{
test: /\.(jpg|png|svg)$/,
//`publicPath` only use to assign assets path in build
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
publicPath: '/'
}
}
]
},
{
test: /\.(woff|woff2|eot|ttf|svg)($|\?)/,
include: [rsuiteStylePath],
use: [
{
loader: 'url-loader',
options: {
limit: 1,
size: 16,
hash: 'sha512',
digest: 'hex',
name: 'resources/[hash].[ext]',
publicPath: '/'
}
}
]
}
]
},
plugins: [
extractLess,
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /zh-cn|en-gb/),
new webpack.NamedModulesPlugin(),
new HtmlwebpackPlugin({
title: 'Wakatime Dashboard',
chunks: ['commons', 'app'],
template: 'src/index.html',
inject: true
})
// new BundleAnalyzerPlugin({ openAnalyzer: false })
]
};