question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Style in vue files is ignored when `sideEffects: false` is defined in package.json

See original GitHub issue

Bug report

Version

0.14.0

Steps to reproduce

Create a vue component in .vuepress/components

<template>
  <p class="red">Should be red</p>
</template>

<style scoped>
.red {
  color: red
}
</style>

Add "sideEffects": false to package.json file

The scoped attribute doesn’t have an impact

What is expected?

When runnig the build, the css should be extracted in a CSS file

What is actually happening?

The CSS is dropped at some point, but it works correctly under dev

Other relevant information

  • Your OS: latest osx
  • Node.js version: 10
  • Browser version: Chrome
  • Is this a global or local install? local
  • Which package manager did you use for the install? yarn

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
ulivzcommented, Aug 12, 2018

I found a related issue: https://github.com/webpack/webpack/issues/6741.

CSS usually doesn’t produce an export, so it really should be excluded from tree shaking.

After change sideEffects: false to:

  "sideEffects": [
    "*.vue"
  ],

The style comes back.

3reactions
posvacommented, Aug 12, 2018

Finally found the problem: it’s adding sideEffects: false to package.json file (it’s a webpack thing for libraries). I created a pull request adding that to the package.json file: https://github.com/ulivz/vuepress-718/pull/1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack not loading Vue's single file components CSS
The HTML and Vue is rendered correctly but without CSS. It seems to be an issue with webpack configuration. Any idea what's wrong?...
Read more >
Tree Shaking - webpack
Tree shaking is a term commonly used in the JavaScript context for dead-code elimination. It relies on the static structure of ES2015 module...
Read more >
Server-Side Rendering (SSR) - Vue.js
Rendering an App # · Create a new directory and cd into it · Run npm init -y · Add "type": "module" in...
Read more >
TSConfig Reference - Docs on every TSConfig option
A file specified by exclude can still become part of your codebase due to an import ... code is ignored; false raises compiler...
Read more >
How To Make Tree Shakeable Libraries - Theodo blog
json file. It is by default set to true when unspecified (there are side effects in every module of the package). You can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found