mirror of
https://github.com/thilo-behnke/wasm-pong.git
synced 2026-05-24 04:32:46 +00:00
84 lines
1.7 KiB
JavaScript
84 lines
1.7 KiB
JavaScript
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
const path = require('path');
|
|
const sveltePreprocess = require('svelte-preprocess');
|
|
|
|
const mode = process.env.NODE_ENV || 'development';
|
|
const prod = mode === 'production';
|
|
|
|
module.exports = {
|
|
entry: './src/main.ts',
|
|
resolve: {
|
|
alias: {
|
|
svelte: path.dirname(require.resolve('svelte/package.json'))
|
|
},
|
|
extensions: ['.mjs', '.js', '.ts', '.svelte'],
|
|
mainFields: ['svelte', 'browser', 'module', 'main']
|
|
},
|
|
output: {
|
|
path: path.join(__dirname, '/dist'),
|
|
filename: '[name].js',
|
|
chunkFilename: '[name].[id].js'
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ts$/,
|
|
loader: 'ts-loader',
|
|
exclude: /node_modules/
|
|
},
|
|
{
|
|
test: /\.svelte$/,
|
|
use: {
|
|
loader: 'svelte-loader',
|
|
options: {
|
|
compilerOptions: {
|
|
dev: !prod
|
|
},
|
|
emitCss: prod,
|
|
hotReload: !prod,
|
|
preprocess: sveltePreprocess({ sourceMap: !prod })
|
|
}
|
|
}
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
use: [
|
|
MiniCssExtractPlugin.loader,
|
|
'css-loader'
|
|
]
|
|
},
|
|
{
|
|
// required to prevent errors from Svelte on Webpack 5+
|
|
test: /node_modules\/svelte\/.*\.mjs$/,
|
|
resolve: {
|
|
fullySpecified: false
|
|
}
|
|
}
|
|
]
|
|
},
|
|
mode,
|
|
plugins: [
|
|
new MiniCssExtractPlugin({
|
|
filename: '[name].css'
|
|
}),
|
|
new CopyWebpackPlugin(['index.html'])
|
|
],
|
|
devtool: prod ? false : 'source-map',
|
|
devServer: {
|
|
hot: true,
|
|
publicPath: '/pong/web/',
|
|
openPage: 'pong/web/',
|
|
open: true,
|
|
proxy: {
|
|
'/pong/api': {
|
|
target: 'http://localhost:4000',
|
|
pathRewrite: { '^/pong/api': '' }
|
|
}
|
|
}
|
|
},
|
|
experiments: {
|
|
asyncWebAssembly: true
|
|
}
|
|
};
|