PlantCtrl/rust/src_webpack/webpack.config.js

64 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-12-04 21:38:21 +01:00
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
const CopyPlugin = require("copy-webpack-plugin");
2024-12-04 21:38:21 +01:00
const isDevServer = process.env.WEBPACK_SERVE;
console.log("Dev server is " + isDevServer);
var host;
if (isDevServer){
2024-12-17 01:39:47 +01:00
host = 'http://192.168.1.172';
2024-12-04 21:38:21 +01:00
} else {
host = '';
}
module.exports = {
mode: "development",
entry: ['./src/main.ts'],
devtool: 'inline-source-map',
2024-12-04 21:38:21 +01:00
plugins: [
new webpack.DefinePlugin({
PUBLIC_URL: JSON.stringify(host),
}),
new webpack.EnvironmentPlugin({
redirect: 'true'
}),
new HtmlWebpackPlugin({
alwaysWriteToDisk: true,
title: "PlantCtrl",
}),
new HtmlWebpackHarddiskPlugin(),
new CopyPlugin({
patterns: [
{
from: "public/bootstrap-grid.css",
to: "bootstrap-grid.css",
}
],
}),
2024-12-04 21:38:21 +01:00
],
module: {
rules: [
2024-12-11 21:01:11 +01:00
{
test: /\.html$/,
2024-12-17 01:39:47 +01:00
type: 'asset/source',
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
2024-12-11 21:01:11 +01:00
}
]
},
resolve: {
2024-12-11 21:01:11 +01:00
extensions: ['.tsx', '.ts', '.js', '.html'],
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, '../src/webserver'),
},
2024-12-04 21:38:21 +01:00
devServer: {
}
};