webpack copies the folder to the specified directory

1. Install the copy-webpack-plugin plugin

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

2. Introduced in the webpack configuration file

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

3. Use in webpack configuration file

const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = merge(webpackBaseConfig, {
    
    
    //其他配置代码省略...
    //在插件这里使用引入的复制文件夹插件
    plugins: [
        new CopyWebpackPlugin([
            {
    
    
               from:'./src/lib/map',//想要复制的文件夹
               to:'map' //复制在哪个文件夹
            }
        ])
    ]
});

4. Pack, then view
insert image description here

Guess you like

Origin blog.csdn.net/weixin_42821697/article/details/123133525