mirror of https://github.com/webpack/webpack.git
41 lines
811 B
JavaScript
41 lines
811 B
JavaScript
|
/** @type {import("../../../../").Configuration} */
|
||
|
module.exports = {
|
||
|
target: "web",
|
||
|
mode: "development",
|
||
|
output: {
|
||
|
uniqueName: "test"
|
||
|
},
|
||
|
plugins: [
|
||
|
{
|
||
|
apply(compiler) {
|
||
|
compiler.hooks.compilation.tap("Test", compilation => {
|
||
|
compilation.hooks.processAssets.tap(
|
||
|
{
|
||
|
name: "Test",
|
||
|
stage:
|
||
|
compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
|
||
|
},
|
||
|
assets => {
|
||
|
const name = "bundle0.css";
|
||
|
const code = assets[name].source();
|
||
|
|
||
|
compilation.updateAsset(
|
||
|
name,
|
||
|
new compiler.webpack.sources.RawSource(
|
||
|
`${code.replace(
|
||
|
"head{",
|
||
|
".class, head, body{"
|
||
|
)}\n\n.after-head { color: red; }`
|
||
|
)
|
||
|
);
|
||
|
}
|
||
|
);
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
],
|
||
|
experiments: {
|
||
|
css: true
|
||
|
}
|
||
|
};
|