-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
66 lines (63 loc) · 1.4 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
const path = require('path');
// Modules
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = () => {
const SRC_PATH = path.resolve(__dirname, 'src');
const DIST_PATH = path.resolve(__dirname, 'public/dist');
return {
entry: {
'index': './src/scripts/index.ts'
},
output: {
path: DIST_PATH,
filename: 'js/[name].bundle.js'
},
plugins: [
// For CSS
new MiniCssExtractPlugin({
path: DIST_PATH,
filename: 'css/[name].css',
}),
],
module: {
rules: [
// TypeScript (Babel)
{
test: /\.ts$/,
include: path.join(SRC_PATH, 'scripts'),
loader: 'babel-loader?cacheDirectory',
exclude: /node_modules/,
},
// SCSS
{
test: /\.scss$/,
include: path.join(SRC_PATH, 'styles'),
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
url: false
}
},
'sass-loader'
]
}
]
},
resolve: {
extensions: ['.ts', '.js']
},
devServer: {
contentBase: path.resolve(__dirname, 'public'),
port: 3000,
publicPath: '/public/'
},
optimization: {
splitChunks: {
name: 'vendor',
chunks: 'initial',
}
},
};
};