Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x | const path = require("path");
const webpack = require("webpack");
//内存文件系统
const Memoryfs = require("memory-fs");
module.exports = (fixture, options = {}) => {
const compiler = webpack({
mode:'development',
context: __dirname,
entry: `./${fixture}`,
output: {
path: path.resolve(__dirname),
filename: "bundle.js"
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: path.resolve(__dirname, "../src/index.js"),
options
}
}
]
}
});
const fs=new Memoryfs();
compiler.outputFileSystem = fs;
return new Promise((resolve, reject) => {
compiler.run((err, stats) => {
Iif (err) {
console.error(err.stack || err);
if (err.details) {
console.error(err.details);
}
reject(err);
return;
}
const info = stats.toJson();
Iif (stats.hasErrors()) {
console.error(info.errors);
}
Iif (stats.hasWarnings()) {
console.warn(info.warnings);
}
resolve(stats);
});
});
};
|