Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--modern flag does't work when config prefetch's fileBlackList in chainWebpack. #2767

Closed
heguichuan opened this issue Oct 17, 2018 · 2 comments
Labels
needs team repro We acknowledged your report and will soon try to reproduce it scope: cli-service build

Comments

@heguichuan
Copy link

Version

3.0.5

Reproduction link

https://github.com/heguichuan/vuecli3-issue

Node and OS info

Node 8.11.3 / Windows 7

Steps to reproduce

  1. npm install

  2. npm run modern

// i init project with vue-cli3 , just add vue.config.js with something in it.

What is expected?

build successfully.

What is actually happening?

vue-cli-service build --modern

  • Building legacy bundle for production... ERROR TypeError: Cannot read property 'fileBlacklist' of undefined
    TypeError: Cannot read property 'fileBlacklist' of undefined
    at config.plugin.tap.options (E:\TEST\vuecli3-issue\vue.config.js:8:45)
    at Object.tap (E:\TEST\vuecli3-issue\node_modules\webpack-chain\src\Plugin.js:24:24)
    at chainWebpack (E:\TEST\vuecli3-issue\vue.config.js:7:31)
    ……
@LinusBorg LinusBorg added scope: cli-service build needs team repro We acknowledged your report and will soon try to reproduce it labels Oct 17, 2018
@LinusBorg
Copy link
Member

This happens because that plugin is only added for the modern bundle, not the legacy bundle.

https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/config/app.js#L155-L171

You should be able to fix your config like this:

module.exports = {
  chainWebpack: config => {
    if (config.plugins.has('prefetch')) {
      config.plugin('prefetch').tap(options => {
        options[0].fileBlacklist = options[0].fileBlacklist || []
        options[0].fileBlacklist.push(/myasyncRoute(.)+?/)
        return options
      })
    }
  }
}

@heguichuan
Copy link
Author

This happens because that plugin is only added for the modern bundle, not the legacy bundle.

https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/config/app.js#L155-L171

You should be able to fix your config like this:

module.exports = {
  chainWebpack: config => {
    if (config.plugins.has('prefetch')) {
      config.plugin('prefetch').tap(options => {
        options[0].fileBlacklist = options[0].fileBlacklist || []
        options[0].fileBlacklist.push(/myasyncRoute(.)+?/)
        return options
      })
    }
  }
}

done it!, Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs team repro We acknowledged your report and will soon try to reproduce it scope: cli-service build
Projects
None yet
Development

No branches or pull requests

2 participants