vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.75k stars 6.32k forks source link

When the environment variable NODE_ENV is set to test, code splitting does not take effect when vue-cli-service build is executed #6928

Closed fanbinghuadev closed 2 years ago

fanbinghuadev commented 2 years ago

Version

4.5.15

Environment info

System:                                                                                                                                                                            
OS: Windows 10 10.0.19042
CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1130G7 @ 1.10GHz
Binaries:
Node: 16.13.0 - D:\nodejs\node.EXE
Yarn: Not Found
npm: 8.1.0 - D:\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Spartan (44.19041.1266.0), Chromium (97.0.1072.55)
npmPackages:
@vue/babel-helper-vue-jsx-merge-props:  1.2.1
@vue/babel-helper-vue-transform-on:  1.0.2
@vue/babel-plugin-jsx:  1.1.1
@vue/babel-plugin-transform-vue-jsx:  1.2.1
@vue/babel-preset-app:  4.5.15
@vue/babel-preset-jsx:  1.2.4
@vue/babel-sugar-composition-api-inject-h:  1.2.1
@vue/babel-sugar-composition-api-render-instance:  1.2.4
@vue/babel-sugar-functional-vue:  1.2.2
@vue/babel-sugar-inject-h:  1.2.2
@vue/babel-sugar-v-model:  1.2.3
@vue/babel-sugar-v-on:  1.2.3
@vue/cli-overlay:  4.5.15
@vue/cli-plugin-babel: 4.5.0 => 4.5.0
@vue/cli-plugin-eslint: 4.5.0 => 4.5.0
@vue/cli-plugin-router: 4.5.0 => 4.5.0
@vue/cli-plugin-vuex: 4.5.0 => 4.5.0
@vue/cli-service: 4.5.0 => 4.5.0
@vue/cli-shared-utils:  4.5.15
@vue/component-compiler-utils:  3.3.0
@vue/eslint-config-standard: 5.1.2 => 5.1.2
@vue/preload-webpack-plugin:  1.1.2
@vue/web-component-wrapper:  1.3.0
eslint-plugin-vue: 6.2.2 => 6.2.2
vue: 2.6.11 => 2.6.11
vue-eslint-parser:  7.11.0
vue-hot-reload-api:  2.3.4
vue-loader:  15.9.8 (16.8.3)
vue-router: 3.2.0 => 3.2.0
vue-style-loader:  4.1.3
vue-template-compiler: 2.6.11 => 2.6.11
vue-template-es2015-compiler:  1.9.1
vuex: 3.4.0 => 3.4.0                                                        

Steps to reproduce

vue-cli-service build --mode test

What is expected?

dynamic import generate seperate chunks

What is actually happening?

dynamic import not generate sepearte chunks

LinusBorg commented 2 years ago

TEST is for unit tetsts, not a build. It's recommended to uset his strategy when you want to do a build that has I.e. different config values:

https://cli.vuejs.org/guide/mode-and-env.html#example-staging-mode

fanbinghuadev commented 2 years ago

TEST is for unit tetsts, not a build. It's recommended to uset his strategy when you want to do a build that has I.e. different config values:

https://cli.vuejs.org/guide/mode-and-env.html#example-staging-mode

Thanks,I know. But I'm trying to figure out if this is a limitation of webpack or vue cli

LinusBorg commented 2 years ago

Vue CLI. And if you want to, you can certanly dig into the webpack config and adjust it.

fanbinghuadev commented 2 years ago

Vue CLI. And if you want to, you can certanly dig into the webpack config and adjust it.

Can you tell me where vue cli does this restriction? I've been looking for a long time, but I can't find it

LinusBorg commented 2 years ago

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