webpack/test/statsCases/define-plugin/webpack.config.js

88 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

"use strict";
2025-04-22 18:49:30 +08:00
const fs = require("fs");
const join = require("path").join;
2025-07-03 17:06:45 +08:00
const webpack = require("../../../");
2025-04-22 20:42:33 +08:00
/**
* @param {string} path path
* @returns {string} JSON content of a file
*/
function read(path) {
return JSON.stringify(
fs.readFileSync(join(__dirname, path), "utf8").replace(/\r\n?/g, "\n")
);
}
/** @type {import("../../../").Configuration[]} */
2015-09-03 20:17:11 +08:00
module.exports = [
{
mode: "production",
2015-09-03 20:17:11 +08:00
entry: "./index",
output: {
filename: "123.js"
},
2015-09-03 20:17:11 +08:00
plugins: [
new webpack.DefinePlugin({
VALUE: "123"
})
]
},
2018-01-19 16:21:00 +08:00
2015-09-03 20:17:11 +08:00
{
mode: "production",
2015-09-03 20:17:11 +08:00
entry: "./index",
output: {
filename: "321.js"
},
2015-09-03 20:17:11 +08:00
plugins: [
new webpack.DefinePlugin({
VALUE: "321"
})
]
},
{
mode: "production",
entry: "./index",
output: {
filename: "both.js"
},
plugins: [
new webpack.DefinePlugin({
2021-05-11 15:31:46 +08:00
VALUE: webpack.DefinePlugin.runtimeValue(
() => read("123.txt"),
[join(__dirname, "./123.txt")]
)
}),
new webpack.DefinePlugin({
2021-05-11 15:31:46 +08:00
VALUE: webpack.DefinePlugin.runtimeValue(
() => read("321.txt"),
[join(__dirname, "./321.txt")]
)
})
]
2023-04-24 02:42:05 +08:00
},
{
mode: "production",
entry: "./index",
output: {
2023-04-26 10:41:52 +08:00
filename: "log.js"
2023-04-24 02:42:05 +08:00
},
infrastructureLogging: {
debug: /DefinePlugin/,
level: "none"
},
stats: {
loggingDebug: /DefinePlugin/,
logging: "none"
},
plugins: [
new webpack.DefinePlugin({
VALUE: "123"
})
]
2015-09-03 20:17:11 +08:00
}
];