farpatch-ui/webpack.config.ts
Sean Cross 0a3b6fe96e convert webpack to typescript
This allows us to add a mock library for simulating the real device.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-03 16:58:54 +08:00

53 lines
1.3 KiB
TypeScript

const path = require('path');
const CopyPlugin = require("copy-webpack-plugin");
const OUTPUT = "build";
import { installMiddlewares } from './mock/webpack.farpatch';
module.exports = {
mode: 'development',
entry: path.resolve(__dirname, './src/index.ts'),
plugins: [
new CopyPlugin({
patterns: [
{ from: "static", to: path.resolve(__dirname, OUTPUT) },
{ from: "node_modules/xterm/css/xterm.css", to: path.resolve(__dirname, OUTPUT, 'css') }
],
}),
],
performance: {
maxAssetSize: 512000
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.ts', '.js'],
},
output: {
filename: 'main.js',
path: path.resolve(__dirname, OUTPUT),
},
devServer: {
static: {
directory: path.resolve(__dirname, OUTPUT),
},
compress: true,
port: 9000,
setupMiddlewares: (middlewares: any, devServer: any) => {
if (!devServer) {
throw new Error('webpack-dev-server is not defined');
}
installMiddlewares(devServer.app);
return middlewares;
}
},
};