-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.common.ts
More file actions
50 lines (47 loc) · 1.15 KB
/
webpack.common.ts
File metadata and controls
50 lines (47 loc) · 1.15 KB
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
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import * as path from 'path';
import * as webpack from 'webpack';
const config: webpack.Configuration = {
entry: './src/js/index.tsx',
plugins: [
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ['index.html', 'bundle.*.js'],
}),
new HtmlWebpackPlugin({ template: 'src/index.html' }),
],
output: {
filename: 'bundle.[contenthash].js',
path: path.join(__dirname, 'public/'),
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: 'ts-loader',
},
{
test: /\.s[ac]ss$/i,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
url: false,
// 0 => no loaders (default);
// 1 => postcss-loader;
// 2 => postcss-loader, sass-loader
importLoaders: 2,
},
},
'sass-loader',
],
},
],
},
resolve: {
extensions: ['.js', '.ts', '.tsx', '.json'],
},
};
export default config;