webpack 配置忽略打包文件夹

最后更新于:2020-09-05 15:53:05 | 78 次浏览

第一步当然是下载依赖

npm install copy-webpack-plugin --save-dev

然后将插件添加到您的webpack配置中。例如:

let path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
  plugins: [
    new CopyPlugin({
      patterns: [
        { from: path.resolve(__dirname, './static'), to: 'static' },
      ],
    }),
  ],
};

配置完成重启项目。static在webpack中就不会在打包,而生成的静态资源文件夹