我使用 copy-webpack-plugin 10.2.0 和 webpack 5.65.0。我想將檔案public/js夾中的js 檔案復制到dist/js.
plugins: [
new CopyWebpackPlugin({
patterns:[
{
from:'public/js/*.js',
to:path.resolve(__dirname, 'dist','js'),
}
]
})
],
但是設定也將路徑復制到dist中,它變成了dist/js/public/js。我嘗試添加flatten:true但它有錯誤
Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
- options.patterns[0] has an unknown property 'flatten'. These properties are valid:
object { from, to?, context?, globOptions?, filter?, transformAll?, toType?, force?, priority?, info?, transform?, noErrorOnMissing? }
那怎么弄呢?
uj5u.com熱心網友回復:
您可以to使用[name]和[ext]組件在引數中設定檔案名,并簡單地省略該path部分。
plugins: [
new CopyWebpackPlugin({
patterns:[
{
from:'public/js/*.js',
to:path.resolve(__dirname, 'dist','js', '[name][ext]'),
}
]
})
],
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/407939.html
標籤:
上一篇:Xamarin-有按鈕呼叫鍵盤
