1. ホーム
  2. ウェブパック

webpack - 定番で便利なプラグイン copy-webpack-plugin webpack用コピーリソースプラグイン

2022-02-28 08:29:42
<パス

- コピーウェブパックプラグイン
webpackでファイルやフォルダをコピーする

cnpm install --save-dev copy-webpack-plugin
new CopyWebpackPlugin([{
    from: __dirname + '/src/public'
}]);
// What it does: Copies all the contents of public to the build directory
from Defines the source directory to copy from: __dirname + '/src/public'
to Defines the destination directory to copy to from: __dirname + '/dist'
toType file or dir Optional, default is file
force force overwrite previous plugins optional default false
context optional default base context available specific context
flatten copies only files regardless of folders default false
ignore Ignore copies the specified files.

new CopyWebpackPlugin([{
    from: __dirname + '/src/public'
}]);
// What it does: Copies all the contents of public to the build directory

from Defines the source directory to copy from: __dirname + '/src/public'
to Defines the destination directory to copy to from: __dirname + '/dist'
toType file or dir Optional, default is file
force force overwrite previous plugins optional default false
context optional default base context available specific context
flatten copies only files regardless of folders default false
ignore Ignore copies the specified files.