-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
65 lines (63 loc) · 1.43 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
const path = require('path');
// Plugins
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
// Config
module.exports = {
entry: './src/app.ts',
mode: 'development',
plugins: [
new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [{ from: './src/index.html' }],
}),
],
module: {
rules: [
{
// Compiles .ts files
test: /\.ts$/i,
loader: 'ts-loader',
exclude: '/node_modules/',
},
{
// Compiles styles (and passes them into bundled file)
test: /\.s[ac]ss$/i,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
// Maintains paths to png files
test: /\.png$/i,
loader: 'file-loader',
options: {
outputPath: 'images',
name: '[name].[ext]',
},
},
{
// Maintains paths to ttf files
test: /\.ttf$/i,
loader: 'file-loader',
options: {
outputPath: 'fonts',
name: '[name].[ext]',
},
},
{
test: /\.svg$/i,
loader: 'svg-url-loader',
},
],
},
resolve: {
extensions: ['.ts', '.js'],
alias: {
'%assets%': path.resolve(__dirname, './assets/'),
'%styles%': path.resolve(__dirname, './src/scss/'),
},
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
};