-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
44 lines (39 loc) · 1.33 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
const { resolve } = require('path');
const { CheckerPlugin, TsConfigPathsPlugin } = require('awesome-typescript-loader');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const isProd = process.env.NODE_ENV === 'production';
const webpackConfig = {
entry: './src/index.tsx',
output: {
path: resolve(__dirname, 'build'),
filename: 'bundle.js',
},
devtool: isProd ? 'source-map' : 'eval-cheap-module-source-map',
resolve: { extensions: ['.js', '.ts', '.tsx'], plugins: [new TsConfigPathsPlugin()] },
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader',
},
{
test: /\.s[ac]ss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
],
},
plugins: [
new HtmlWebpackPlugin({ favicon: './public/favicon.ico', minify: isProd, template: './public/index.html' }),
new CheckerPlugin(),
],
};
if (isProd) {
webpackConfig.mode = 'production';
webpackConfig.devtool = 'source-map';
} else {
webpackConfig.mode = 'development';
webpackConfig.devtool = 'eval-cheap-module-source-map';
webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
}
module.exports = webpackConfig;