2022-01-18 01:39:56 -08:00
|
|
|
const path = require('path');
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
|
2022-07-26 19:03:50 -07:00
|
|
|
const { SourceMapDevToolPlugin } = require('webpack');
|
2022-01-18 01:39:56 -08:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: './web/src/index.js',
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
use: 'swc-loader',
|
|
|
|
exclude: /node_modules/,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.scss$/i,
|
|
|
|
use: [
|
|
|
|
// Creates `style` nodes from JS strings
|
|
|
|
"style-loader",
|
|
|
|
// Translates CSS into CommonJS
|
|
|
|
"css-loader",
|
|
|
|
// Compiles Sass to CSS
|
|
|
|
"sass-loader",
|
2022-07-26 19:03:50 -07:00
|
|
|
// source map for debugging
|
|
|
|
"source-map-loader"
|
2022-01-18 01:39:56 -08:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.tsx', '.ts', '.js'],
|
|
|
|
},
|
|
|
|
output: {
|
2022-01-18 01:52:44 -08:00
|
|
|
path: path.resolve(__dirname, 'dist/static'),
|
2022-01-18 01:39:56 -08:00
|
|
|
filename: 'index.js',
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: path.resolve(__dirname, 'web/src/index.html'),
|
|
|
|
publicPath: "/static",
|
|
|
|
}),
|
|
|
|
new WasmPackPlugin({
|
|
|
|
crateDirectory: path.resolve(__dirname, "web"),
|
|
|
|
outDir: path.resolve(__dirname, "web/pkg"),
|
|
|
|
}),
|
2022-07-26 19:03:50 -07:00
|
|
|
new SourceMapDevToolPlugin({}),
|
2022-01-18 01:39:56 -08:00
|
|
|
],
|
|
|
|
experiments: {
|
|
|
|
asyncWebAssembly: true,
|
|
|
|
},
|
|
|
|
mode: 'development'
|
|
|
|
};
|