PlantCtrl/rust/src_webpack/webpack.config.js
2024-12-17 01:39:47 +01:00

58 lines
1.1 KiB
JavaScript

const webpack = require('webpack');
const CopyPlugin = require("copy-webpack-plugin");
const path = require('path');
const isDevServer = process.env.WEBPACK_SERVE;
console.log("Dev server is " + isDevServer);
var host;
if (isDevServer){
host = 'http://192.168.1.172';
} else {
host = '';
}
module.exports = {
mode: "development",
entry: ['./src/index.ts'],
devtool: 'inline-source-map',
plugins: [
new CopyPlugin({
patterns: [
{
from: "src/index.html",
to: "index.html"
}
]
}),
new webpack.DefinePlugin({
PUBLIC_URL: JSON.stringify(host),
}),
new webpack.EnvironmentPlugin({
redirect: 'true'
})
],
module: {
rules: [
{
test: /\.html$/,
type: 'asset/source',
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.html'],
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, '../src/webserver'),
},
devServer: {
}
};