-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·115 lines (99 loc) · 2.31 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const path = require('path');
const webpack = require('webpack');
const childProcess = require('child_process');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const AppCachePlugin = require('appcache-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
const extractCss = new ExtractTextPlugin('main.css');
const hsm = 'hidden-source-map';
const cme = 'cheap-module-eval-source-map';
const PRODUCTION = process.env.NODE_ENV === 'production';
const DEVTOOL = PRODUCTION ? hsm : cme;
const ENABLE_APPCACHE = true;
module.exports = {
devtool: DEVTOOL,
entry: {
main: [
'core-js/fn/typed',
'core-js/fn/promise',
'core-js/fn/object/assign',
'core-js/fn/array/find',
'core-js/fn/array/includes',
'whatwg-fetch',
'./inc/js/main.js',
],
},
output: {
pathinfo: !PRODUCTION,
filename: '[name].js',
path: path.resolve('./dist')
},
devServer: {
contentBase: path.resolve('./dist'),
historyApiFallback: true,
inline: true,
port: 9000,
},
module: {
rules: [{
test: /\.tsx?$/i,
loader: ['babel-loader', 'ts-loader'],
},
{
test: /\.jsx?$/i,
include: path.resolve('./src'),
use: ['babel-loader'],
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.s[ca]ss$/i,
use: extractCss.extract(['css-loader', 'resolve-url-loader', 'sass-loader?sourceMap=true'])
},
{
test: /\.(woff|woff2|eot|otf|ttf|map|svg|png|gif|jpg)$/i,
use: {
loader: 'file-loader',
options: {
name: 'assets/[name]-[hash:8].[ext]',
},
},
},
],
},
resolve: {
modules: ['./src', 'node_modules'],
extensions: ['.ts', '.tsx', '.js'],
},
node: {
fs: 'empty',
net: 'empty',
},
plugins: [
extractCss,
new webpack.NamedModulesPlugin(),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
minChunks: function (module) {
return /node_modules/i.test(module.resource);
},
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
minChunks: 2,
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity,
}),
new BundleAnalyzerPlugin({
openAnalyzer: false,
analyzerMode: 'static',
reportFilename: 'analysis.html',
})
],
};