Vue-cli: Nested index.html files not being copied to dist folder

Created on 4 Oct 2018  路  5Comments  路  Source: vuejs/vue-cli

Version

3.0.4

Reproduction link

https://github.com/ivansieder/vue-cli-nested-index-files-bug

Node and OS info

Node 10.11.0 / yarn 1.10.1 / Ubuntu 18.04

Steps to reproduce

  • run yarn build

What is expected?

nested index.html files (inside the other directory) should be copied to the dist folder.

What is actually happening?

The index.html files (no matter in which subdirectory) are being ignored.

bug upstream

Most helpful comment

Update on this one: I've opened up a PR for the copy-webpack-plugin (https://github.com/webpack-contrib/copy-webpack-plugin/pull/295) to allow granular file exclusions using a custom validation function. As soon as that is done, it could be implemented with the vue CLI (if this is actually wanted by the core team) to really only exclude those files, which have been used as templates and copy all other files properly.

All 5 comments

This "fix" does actually work, but there is an issue when using multi-page-setup, as in that situation, html-webpack-plugin will take it as a template AND the file will be copied, too. What's the desired output here? Wouldn't it be better to generally copy ALL files, which are not being used as a template somewhere instead of only ignoring index.html files? This way someone could also get the public/index.html copied, if it's not being used as an HTML template.

Update on this one: I've opened up a PR for the copy-webpack-plugin (https://github.com/webpack-contrib/copy-webpack-plugin/pull/295) to allow granular file exclusions using a custom validation function. As soon as that is done, it could be implemented with the vue CLI (if this is actually wanted by the core team) to really only exclude those files, which have been used as templates and copy all other files properly.

I fix it in vue.config.js

{
  ...
  chainWebpack: config => {
    config.plugin('copy').tap(([options]) => {
      options[0].ignore = ['./index.html', '.DS_Store']
      return [options]
    })
  }
}

Hi @panjiang, I am not quiet sure that this is working (mostly for index.html files in sub-folders), because the ignore option matches glob patterns. Does this work for you also for files index.html files in sub folders?

https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/src/processPattern.js#L68

Yes, It worked for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

miyamoto-san picture miyamoto-san  路  3Comments

JIANGYUJING1995 picture JIANGYUJING1995  路  3Comments

Akryum picture Akryum  路  3Comments

OmgImAlexis picture OmgImAlexis  路  3Comments

joshuajohnson814 picture joshuajohnson814  路  3Comments