拷贝文件的插件
加载插件
$ npm install copy-webpack-plugin --save-dev
API
new CopyWebpackPlugin(patterns: Array, options: Object)
- patterns:数组,最常用的每项的格式为
{from: 'path', to: 'path'}
。 - options:其它配置。
示例
目录结构
- build
- test
- src
- test
- test.js
- index.js
- test
- webpack.config.js
配置信息
webpack.config.js
var path = require('path');
var CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: path.resolve(__dirname, 'src'),
output: {
path: path.resolve(__dirname, 'build'),
filename: 'app.js'
},
context: path.resolve(__dirname, 'src'),
plugins: [
new CopyWebpackPlugin([{
from: 'test/test.js',
to: 'test'
}], {
ignore: [],
copyUnmodified: true
})
]
};
执行命令
$ webpack