-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
72 lines (70 loc) · 2.2 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {DefinePlugin} = require('webpack');
const CssExtractPlugin = require('mini-css-extract-plugin');
const sass = require('sass');
const array = (...items) => items.filter(Boolean);
module.exports = (env, {mode}) => ({
entry: './src/index.tsx',
output: {
filename: 'main.js',
path: `${__dirname}/dist`,
},
plugins: array(
new HtmlWebpackPlugin({
template: 'src/index.html',
inject: true,
}),
new DefinePlugin({
__DEVELOPMENT__: mode === 'development',
__PRODUCTION__: mode === 'production',
}),
mode !== 'development' && new CssExtractPlugin(),
),
module: {
rules: [{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
}, {
test: /\.scss$/,
exclude: /node_modules/,
use: [
mode === 'development' ? 'style-loader' : CssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1,
modules: {
mode: 'local',
localIdentName: mode === 'development' ? '[name]__[local]__[hash:base64]' : '[hash:base64]',
},
}
},
{
loader: 'sass-loader',
options: {
implementation: sass,
},
}
],
}],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
alias: {
'~components': `${__dirname}/src/components`,
'~containers': `${__dirname}/src/containers`,
'~core': `${__dirname}/src/core`,
'~utils': `${__dirname}/src/utils`,
'~types': `${__dirname}/src/types`,
'~reducer': `${__dirname}/src/reducer`,
'~shortcuts': `${__dirname}/src/shortcuts`,
'~func': `${__dirname}/src/func`,
},
},
devServer: {
inline: true,
hot: true,
port: 8080,
},
});