-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
79 lines (78 loc) · 2.09 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
67
68
69
70
71
72
73
74
75
76
77
78
79
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
// Basic configuration
entry: './src/index.tsx',
mode: 'development',
// Necessary in order to use source maps and debug directly TypeScript files
devtool: 'eval-source-map',
module: {
rules: [
// Necessary in order to use TypeScript
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.s?[ac]ss$/i,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
implementation: require("sass"),
sassOptions: {
fiber: false,
},
}
}
]
}
],
},
resolve: {
// Alway keep '.js' even though you don't use it.
// https://github.com/webpack/webpack-dev-server/issues/720#issuecomment-268470989
extensions: ['.ts', '.tsx', '.js'],
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
// This line is VERY important for VS Code debugging to attach properly
// Tamper with it at your own risks
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
},
plugins: [
// No need to write a index.html
new HtmlWebpackPlugin({
template: 'src/index.html',
hash: true,
}),
// Do not accumulate files in ./dist
new CleanWebpackPlugin(),
// Copy assets to serve them
new CopyPlugin({
patterns: [{ from: 'assets/c2ints/' }]
}),
],
devServer: {
// webpack-dev-server configuration
// keep port in sync with VS Code launch.json
port: 3000,
// Hot-reloading, the sole reason to use webpack here <3
hot: true,
compress: true,
static: ['dist'],
devMiddleware: {
index: false,
mimeTypes: { phtml: 'text/html' },
publicPath: '/public',
serverSideRender: true,
writeToDisk: true,
},
},
};