-
Notifications
You must be signed in to change notification settings - Fork 23
/
webpack.base.js
118 lines (114 loc) · 2.81 KB
/
webpack.base.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const sveltePreprocess = require('svelte-preprocess');
const mode = process.env.NODE_ENV || 'development';
const prod = mode === 'production';
/**
* @type {import('webpack').Configuration}
*/
const config = {
mode: 'development',
devtool: 'eval-cheap-module-source-map',
module: {
rules: [
{
test: /\.(tsx?)|(js)$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
{
test: /\.hbs$/,
use: 'handlebars-loader',
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.svg$/,
loader: 'svg-inline-loader',
},
{
test: /\.svelte$/,
use: {
loader: 'svelte-loader',
options: {
preprocess: [sveltePreprocess({ typescript: {} })],
compilerOptions: {
dev: !prod,
},
emitCss: prod,
hotReload: !prod,
},
},
},
{
// required to prevent errors from Svelte on Webpack 5+, omit on Webpack 4
test: /node_modules\/svelte\/.*\.mjs$/,
resolve: {
fullySpecified: false,
},
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.wasm', '.svelte', '.mjs'],
modules: [path.resolve('./node_modules'), path.resolve('.')],
alias: {
svelte: path.resolve('node_modules', 'svelte/src/runtime'),
},
conditionNames: ['require', 'node', 'svelte'],
},
plugins: [
new HtmlWebpackPlugin({
alwaysWriteToDisk: true,
title: 'Web Synth - Realtime Browser Audio Synthesis Plaform',
minify: true,
template: 'src/index.hbs',
chunks: ['index'],
}),
new HtmlWebpackPlugin({
alwaysWriteToDisk: true,
title: 'Rust + Wasm-powered FM Synthesizer',
minify: true,
template: 'src/fm-synth-demo.hbs',
filename: 'fm.html',
hash: true,
chunks: ['fmDemo'],
}),
new webpack.EnvironmentPlugin(['BACKEND_BASE_URL', 'FAUST_COMPILER_ENDPOINT']),
],
devServer: {
port: 9000,
historyApiFallback: true,
host: '0.0.0.0',
hot: true,
client: {
overlay: {
warnings: false,
errors: true,
},
},
headers: {
// Support sending `SharedArrayBuffer` between threads
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
},
},
experiments: {
syncWebAssembly: true,
backCompat: false,
// outputModule: true,
},
};
module.exports = config;