How does vue-cli package txt files under the dist folder and at the same level as index.html?

Environment:

vue-cli is version 2.0
Wechat official account needs to be placed in the background MP_verify_VyzrblyR8JxLFfPS.txt this file

question:

now I want to package the txt file into the project file dist through the configuration of webpack. What can I do?

Project path:
clipboard.png


CopyWebpackPlugin-webpack plug-in, syntax is as follows

new CopyWebpackPlugin([{ from: '**/*', to: 'relative/path/to/dest/' }
    { from: '**/*', to: '/absolute/path/to/dest/' }
  ], options)

< H2 > you can achieve < / H2 > by adding arrays to webpack.dev.conf.js and webpack..conf.js.
// copy custom static assets
new CopyWebpackPlugin([
  {
    from: path.resolve(__dirname, '../static'),
    to: config.dev.assetsSubDirectory,
    ignore: ['.*']
  },
  // dist
  {
    from: path.join(__dirname, '../*.txt'),
    to: path.join(__dirname, '../dist/')
  }
])

can be deleted by direct verification. There is no need to keep it in the root directory


if it is 3.0, configure it in config.js.

Menu