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

css file import dose not work when build production files #4832

Closed
BboyAwey opened this issue Nov 12, 2019 · 3 comments
Closed

css file import dose not work when build production files #4832

BboyAwey opened this issue Nov 12, 2019 · 3 comments

Comments

@BboyAwey
Copy link

BboyAwey commented Nov 12, 2019

Version

3.12.1

Reproduction link

https://github.com/BboyAwey/vue-cli-css-file-lose-while-building-production-files

Environment info

System:
    OS: macOS 10.15
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  Binaries:
    Node: 8.12.0 - /usr/local/bin/node
    Yarn: 1.9.4 - /usr/local/bin/yarn
    npm: 5.1.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 78.0.3904.97
    Firefox: 70.0.1
    Safari: 13.0.2
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0
    @vue/babel-plugin-transform-vue-jsx:  1.1.2
    @vue/babel-preset-app:  3.12.1
    @vue/babel-preset-jsx:  1.1.2
    @vue/babel-sugar-functional-vue:  1.1.2
    @vue/babel-sugar-inject-h:  1.1.2
    @vue/babel-sugar-v-model:  1.1.2
    @vue/babel-sugar-v-on:  1.1.2
    @vue/cli-overlay:  3.12.1
    @vue/cli-plugin-babel: ^3.12.0 => 3.12.1
    @vue/cli-plugin-eslint: ^3.12.0 => 3.12.1
    @vue/cli-plugin-unit-jest: ^3.12.0 => 3.12.1
    @vue/cli-service: ^3.12.0 => 3.12.1
    @vue/cli-shared-utils:  3.12.1
    @vue/component-compiler-utils:  3.0.2
    @vue/eslint-config-standard: ^4.0.0 => 4.0.0
    @vue/preload-webpack-plugin:  1.1.1
    @vue/test-utils: 1.0.0-beta.29 => 1.0.0-beta.29
    @vue/web-component-wrapper:  1.2.0
    eslint-plugin-vue: ^5.0.0 => 5.2.3 (4.7.1)
    jest-serializer-vue:  2.0.2
    vue: ^2.6.10 => 2.6.10
    vue-eslint-parser:  5.0.0 (2.0.3)
    vue-hot-reload-api:  2.3.4
    vue-jest:  3.0.5
    vue-loader:  15.7.2
    vue-router: ^3.0.3 => 3.1.3
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.6.10 => 2.6.10
    vue-template-es2015-compiler:  1.9.1
    vuex: ^3.0.1 => 3.1.2
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

1.run yarn to install all deps
2.run yarn serve to start dev server
I imported a css file from admin-ui/dist/style.css in main.js, and It works fine. Then we build:
3.run yarn build to build production files
and check the dist dir, the code from that css file is missing!!
Then I create another directory in node_modules and put a css file in it and import it in main.js, then build again, it works fine!!
Magic!!!

What is expected?

The code from css file admin-ui/dist/style.css should work and show themselves in production files.

What is actually happening?

The code from css file admin-ui/dist/style.css works fine when in dev mode but disappear in production files


What a magic moment!!

@haoqunjiang
Copy link
Member

haoqunjiang commented Nov 12, 2019

https://vue-loader.vuejs.org/guide/#manual-setup
Scroll to the bottom.

If you are developing a library or in a monorepo, please be aware that CSS imports are side effects. Make sure to remove "sideEffects": false in the package.json, otherwise CSS chunks will be dropped by webpack in production builds.

@haoqunjiang
Copy link
Member

I know it's not the best place to put such a warning… Maybe we need to put it in the Vue CLI documentation.

haoqunjiang added a commit to haoqunjiang/vue-cli that referenced this issue Nov 12, 2019
These warnings are originally stated in the vue-loader documentation,
but the CLI documentation perhaps have more visibility.

Fixes vuejs#4832
@BboyAwey
Copy link
Author

Oh that's a little bit awkward. I Appreciate your support,Thanks a lot!

NataliaTepluhina pushed a commit that referenced this issue Nov 21, 2019
These warnings are originally stated in the vue-loader documentation,
but the CLI documentation perhaps have more visibility.

Fixes #4832
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants