webpackremove-empty脚本正在删除asset.php文件



我正在使用带有此插件的Webpack 5:https://github.com/webdiscus/webpack-remove-empty-scripts

构建过程正在运行@WordPress/Scripts。这还将为生成的每个CSS文件输出一个asset.php文件。

我想使用这个插件来删除用编译的CSS文件创建的.JS文件。这些.JS文件是空的,放在里面很烦人。

当使用插件时,它也会删除我的asset.php文件。我已经尝试了包括忽略asset.php文件在内的选项,但它仍然不起作用。

有什么想法吗?下面是我的代码:


const otherStyleConfig = {
...defaultConfig,
entry: {
'blog': path.resolve( './src/sass', 'blog.scss' ),
'editor': path.resolve( './src/sass', 'editor.scss' ),
'header-footer': path.resolve( './src/sass', 'header-footer.scss' ),
'partners': path.resolve( './src/sass', 'partners.scss' ),
'posts-and-pages': path.resolve( './src/sass', 'posts-and-pages.scss' ),
'resource-center': path.resolve( './src/sass', 'resource-center.scss' ),
'resource-single': path.resolve( './src/sass', 'resource-single.scss' ),
'support-center': path.resolve( './src/sass', 'support-center.scss' ),
'table-of-contents': path.resolve( './src/sass', 'table-of-contents.scss' ),
'widgets': path.resolve( './src/sass', 'widgets.scss' ),
},
module: {
rules: [
{
test: /.scss$/,
exclude: /node_modules/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
url: false, //Don't do anything with image url's
},
},
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [
sortMediaQueries(),
presetEnv(),
mergeLonghand(),
mergeRules(),
cssnano( {
reduceIdents: false,
zindex: false,
autoprefixer: false,
} ),
],
options: {},
},
},
},
'resolve-url-loader',
'sass-loader',
],
},
],
},
output: {
path: path.resolve(__dirname, 'build/css'),
},
devtool: 'source-map',
plugins: [
new MiniCssExtractPlugin(),
new DependencyExtractionWebpackPlugin(),
new RemoveEmptyScriptsPlugin({
verbose: true,
ignore: [
/.*asset.php$/,
]
}),
]
}

该问题在webpack remove empty scripts v0.8.4及更高版本中得到修复。

最新更新