mirror of https://github.com/webpack/webpack.git
34 lines
714 B
JavaScript
34 lines
714 B
JavaScript
"use strict";
|
|
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
module.exports = {
|
|
findBundle() {
|
|
return ["dir_module_js.bundle0.js", "bundle0.js"];
|
|
},
|
|
afterExecute(options) {
|
|
const outputPath = options.output.path;
|
|
const files = fs.readdirSync(outputPath);
|
|
|
|
for (const file of files) {
|
|
const filename = path.resolve(outputPath, file);
|
|
const source = fs.readFileSync(filename, "utf8");
|
|
|
|
switch (file) {
|
|
case "resource-with-bom.ext": {
|
|
if (!/[\uFEFF]/.test(source)) {
|
|
throw new Error(`Not found BOM in ${filename}.`);
|
|
}
|
|
break;
|
|
}
|
|
default: {
|
|
if (/\uFEFF/.test(source)) {
|
|
throw new Error(`Found BOM in ${filename}.`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|