Vue-cli: --modern flag does't work when config prefetch's fileBlackList in chainWebpack.

Created on 17 Oct 2018  Â·  2Comments  Â·  Source: vuejs/vue-cli

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)
    ……
needs team repro cli-service build

Most helpful comment

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
      })
    }
  }
}

All 2 comments

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
      })
    }
  }
}

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

b-zee picture b-zee  Â·  3Comments

JIANGYUJING1995 picture JIANGYUJING1995  Â·  3Comments

DrSensor picture DrSensor  Â·  3Comments

BusyHe picture BusyHe  Â·  3Comments

Akryum picture Akryum  Â·  3Comments