copy-webpack-plugin最简使用示例

拷贝文件的插件

加载插件

$ 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
  • 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

参考地址

https://github.com/kevlened/copy-webpack-plugin

上一篇:kbmMW User authentication


下一篇:C/C++笔试题(很多)