-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.ts
67 lines (63 loc) · 1.35 KB
/
webpack.config.ts
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
import webpack, { NewUseRule } from 'webpack';
import * as path from 'path';
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
import * as Clean from 'clean-webpack-plugin';
const rules: NewUseRule[] = [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
exclude: /node_modules/,
enforce: 'pre',
use: 'typed-css-modules-loader'
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
include: /react-ui/
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]'
],
exclude: /react-ui/
},
{
test: /\.(png|jpg|svg|woff|woff2|eot)$/,
use: 'file-loader'
}
];
const plugins = [
new HtmlWebpackPlugin({
filename: './index.html',
template: path.join(__dirname, 'src/public/index.html'),
inject: 'body'
}),
new Clean(['dist/app'])
];
const config: webpack.Configuration = {
context: path.join(__dirname, 'src'),
entry: {
main: './index.tsx'
},
output: {
publicPath: '/',
path: path.join(__dirname, 'dist', 'app'),
filename: 'assets/[name].[hash].js',
chunkFilename: 'assets/[id].js'
},
devtool: 'eval',
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
module: {
rules
},
plugins
};
export default config;