Path: blob/main/desktop/electron/webpack.config.js
1067 views
/*1This is a minimal webpack config file for using python-wasm in a frontend2Javascript project that uses WebPack 5 (and Typescript). There are two3small things that you must:45- The NodePolyfillPlugin is needed because python-wasm6uses memfs, which requires several polyfilled libraries.78- The wasm and zip asset/resource rules are needed so python-wasm9can import the python wasm binary and zip filesystem.1011*/1213const { resolve } = require("path");14const HtmlWebpackPlugin = require("html-webpack-plugin");15const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");1617module.exports = {18mode: process.env.NODE_ENV == "production" ? "production" : "development",19entry: "./src/renderer.ts",20devtool: "inline-source-map",21output: {22filename: "[name].bundle.js",23path: resolve(__dirname, "dist/renderer"),24clean: true,25},26plugins: [27new NodePolyfillPlugin() /* required for python-wasm */,28new HtmlWebpackPlugin({29title: "CoWasm Desktop",30}),31],32module: {33rules: [34{35test: /\.wasm$|\.zip$|\.tar.xz$/ /* required for python-wasm */,36type: "asset/resource",37},38{39test: /\.tsx?$/,40use: "ts-loader",41exclude: /node_modules/,42},43{44test: /\.css$/i,45use: ["style-loader", "css-loader"],46},47],48},49resolve: {50extensions: [".tsx", ".ts", ".js"],51},52};535455