-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.common.js
141 lines (135 loc) · 3.89 KB
/
webpack.config.common.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// shared config (dev and prod)
const webpack = require('webpack');
const { resolve } = require('path');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const SLASH_ESCAPE_LESS_WITH_EXTRACT_PLUGIN = "\\/\\/";
module.exports = {
resolve: {
alias: {
'@': resolve(__dirname, 'src/')
},
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js', '.jsx'],
},
// context: resolve(__dirname, 'src'), <- what was that for?!
/* entry - to be defined by each env */
output: { // this looks identical for both
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js',
// the output bundle
path: resolve(__dirname, 'dist'),
publicPath: '/'
// necessary for HMR to know where to load the hot update chunks
},
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{ loader: 'ts-loader',
options: {
happyPackMode: true,
transpileOnly: true
}
}
],
exclude: [/node_modules/],
},
{
test: /\.less$/,
exclude: /node_modules/,
loaders: ExtractTextPlugin.extract({fallback: 'style-loader', use: [
{
loader: "css-loader",
options: {
sourceMap: true,
minimize: true
}
}, {
loader: "postcss-loader",
options: {
sourceMap: 'inline'
}
}, {
loader: "less-loader",
options: {
sourceMap: true,
modifyVars: {
assets: `\'${SLASH_ESCAPE_LESS_WITH_EXTRACT_PLUGIN}localhost:3000\'`
}
}
}]}),
},
{
test: /\.scss$/,
exclude: /node_modules/,
loaders: ExtractTextPlugin.extract({fallback: 'style-loader', use: [ {
loader: "css-loader",
options: {
sourceMap: true,
minimize: true
}
}, {
loader: "postcss-loader",
options: {
sourceMap: 'inline'
}
}, {
loader: "sass-loader",
options: {
sourceMap: true
}
}]}),
},
{
test: /\.css$/,
exclude: /node_modules/,
loaders: ExtractTextPlugin.extract({fallback: 'style-loader', use: [{
loader: "css-loader",
options: {
sourceMap: true,
minimize: true
}
}, {
loader: "postcss-loader",
options: {
sourceMap: true
}
}]}),
},
{
test: /\.json$/,
loader: 'json-loader',
exclude: /node_modules/
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file-loader?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false',
],
},
{
test: /\.html$/,
use: {
loader: 'html-loader'
}
}
],
},
plugins: [
new ExtractTextPlugin({
filename: '[name].css?hash=[hash]',
allChunks: true
}),
new ForkTsCheckerWebpackPlugin({
tslint: true,
checkSyntacticErrors: true,
// watch: ['./src'] // optional but improves performance (fewer stat calls)
}),
new webpack.EnvironmentPlugin({
IS_BROWSER: "true"
})
]
};