bitburner-src/webpack.config-test.js

92 lines
2.1 KiB
JavaScript
Raw Normal View History

/**
* Webpack configuration for building unit tests
*/
2021-09-05 01:09:30 +02:00
/* eslint-disable @typescript-eslint/no-var-requires */
var path = require("path");
var webpack = require("webpack");
2021-05-01 09:17:31 +02:00
module.exports = () => {
2021-09-05 01:09:30 +02:00
const statsConfig = {
builtAt: true,
children: false,
chunks: false,
chunkGroups: false,
chunkModules: false,
chunkOrigins: false,
colors: true,
entrypoints: true,
};
2021-09-05 01:09:30 +02:00
return {
plugins: [
new webpack.DefinePlugin({
"process.env.NODE_ENV": '"development"',
}),
new webpack.ProvidePlugin({
// Automtically detect jQuery and $ as free var in modules
// and inject the jquery library
// This is required by many jquery plugins
// http://stackoverflow.com/questions/29080148/expose-jquery-to-real-window-object-with-webpack
jquery: "jquery",
jQuery: "jquery",
$: "jquery",
}),
],
entry: "./test/index.js",
target: "web",
devtool: "source-map",
output: {
path: path.resolve(__dirname, "./"),
filename: "test/test.bundle.js",
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
},
2021-09-05 01:09:30 +02:00
{
test: /\.(jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
2021-09-05 01:09:30 +02:00
{
test: /\.s?css$/,
loader: "null-loader",
},
2021-09-05 01:09:30 +02:00
],
},
optimization: {
removeAvailableModules: true,
removeEmptyChunks: true,
mergeDuplicateChunks: true,
flagIncludedChunks: true,
occurrenceOrder: true,
sideEffects: true,
providedExports: true,
usedExports: true,
concatenateModules: false,
namedModules: false,
namedChunks: false,
minimize: false,
portableRecords: true,
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: `tests/vendor`,
chunks: "all",
},
},
2021-09-05 01:09:30 +02:00
},
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".jsx"],
},
stats: statsConfig,
};
};