Files
tlsn-js/webpack.web.dev.config.js
tsukino ddcf75fc5f v0.0.2
2023-12-19 21:11:10 -08:00

91 lines
2.2 KiB
JavaScript

const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const { compilerOptions } = require('./tsconfig.json');
const isProd = process.env.NODE_ENV === 'production';
const envPlugin = new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
});
const rules = [
{
test: /\.node$/,
use: 'node-loader',
},
{
test: /\.tsx?$/,
exclude: /(node_modules|.webpack)/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
],
},
];
const rendererRules = [];
module.exports = [
{
target: 'web',
mode: isProd ? 'production' : 'development',
entry: {
test: path.join(__dirname, 'utils', 'web.ts'),
},
output: {
path: __dirname + '/dev-build/web',
publicPath: '/',
filename: `[name].js`,
},
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.png', '.svg'],
modules: [
path.resolve('./node_modules'),
path.resolve(__dirname, compilerOptions.baseUrl),
],
fallback: {
browserify: require.resolve('browserify'),
stream: require.resolve('stream-browserify'),
path: require.resolve('path-browserify'),
crypto: require.resolve('crypto-browserify'),
os: require.resolve('os-browserify/browser'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
assert: require.resolve('assert/'),
events: require.resolve('events/'),
'ansi-html-community': require.resolve('ansi-html-community'),
'html-entities': require.resolve('html-entities'),
constants: false,
fs: false,
},
},
module: {
rules: [...rules, ...rendererRules],
},
plugins: [
envPlugin,
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.ProvidePlugin({
process: 'process',
}),
new HtmlWebpackPlugin({
template: './static/index.template.ejs',
filename: `index.html`,
inject: true,
}),
],
stats: 'minimal',
devServer: {
historyApiFallback: true,
},
},
];