-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.ts
104 lines (101 loc) · 3.41 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import * as path from 'path'
import {Configuration, DefinePlugin, ProvidePlugin} from 'webpack'
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
import 'webpack-dev-server'
module.exports = (env: NodeJS.ProcessEnv): Configuration => {
return {
entry: './src/index.tsx',
mode: 'development',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname) + '/dist',
},
performance: {
hints: false,
maxAssetSize: 512000,
maxEntrypointSize: 512000,
},
devServer: {
static: {
directory: path.join(__dirname, 'public'),
},
compress: false,
hot: true,
port: 4200,
},
experiments: {
asyncWebAssembly: true,
syncWebAssembly: true,
},
// Enable sourcemaps for debugging webpack's output.
devtool: 'source-map',
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.ts', '.tsx', '.js', '.json'],
plugins: [
new TsconfigPathsPlugin({
configFile: './tsconfig.json',
}),
],
},
plugins: [
new ForkTsCheckerWebpackPlugin({
typescript: {configFile: './tsconfig.json'},
}),
new HtmlWebpackPlugin({
publicPath: path.join(__dirname, 'dist'),
template: path.resolve(__dirname, 'public/index.html'),
}),
// https://rustwasm.github.io/wasm-pack/book/commands/build.html
// new WasmPackPlugin({
// crateDirectory: path.resolve(__dirname, 'src/wasms/server'),
// extraArgs: '--mode no-install --target web',
// outDir: 'pkg',
// }),
// new WasmPackPlugin({
// crateDirectory: path.resolve(__dirname, 'src/wasms/fc'),
// extraArgs: '--mode no-install --target web',
// outDir: 'pkg',
// }),
new ProvidePlugin({
React: 'react',
}),
],
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'esbuild-loader',
options: {
loader: 'tsx',
target: 'es2015',
},
},
{
test: /\.css$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
'css-loader',
// Compiles Sass to CSS
'sass-loader',
],
},
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
'css-loader',
// Compiles Sass to CSS
'sass-loader',
],
},
],
},
}
}