vue-cli通过webpack把.txt文件打包到dist文件夹下并且和index.html在同一级目录

使用CopyWebpackPlugin插件,在webpack中copy文件或文件夹

1、下载插件CopyWebpackPlugin

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

2、在build/webpack.base.conf.js文件下使用插件:

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

plugins: [
    new CopyWebpackPlugin([
        {
            from: path.join(__dirname, "../***.txt"),
            to: path.join(__dirname, "../dist/***.txt")
        } 
    ])
]

from 要拷贝的文件路径

to 输出路径

你可能感兴趣的:(webpack,webpack)