Skip to content

vue.config.js: SCSS only works if vue component contains a non-empty style section. #5188

Open
@acarlstein

Description

@acarlstein

Version

4.1.1

Environment info

  System:
    OS: Windows 10 10.0.17763
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 12.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: Not Found
    npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 44.17763.831.0
  npmPackages:
    @fortawesome/vue-fontawesome: ^0.1.9 => 0.1.9
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0
    @vue/babel-plugin-transform-vue-jsx:  1.1.2
    @vue/babel-preset-app:  4.1.2
    @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:  4.1.2
    @vue/cli-plugin-babel: ^4.1.0 => 4.1.2
    @vue/cli-plugin-eslint: ^4.1.0 => 4.1.2
    @vue/cli-plugin-router:  4.1.2
    @vue/cli-plugin-unit-mocha: ^4.1.2 => 4.1.2
    @vue/cli-plugin-vuex:  4.1.2
    @vue/cli-service: ^4.1.0 => 4.1.2
    @vue/cli-shared-utils:  4.1.2
    @vue/component-compiler-utils:  3.1.1
    @vue/preload-webpack-plugin:  1.1.1
    @vue/test-utils: ^1.0.0-beta.30 => 1.0.0-beta.30
    @vue/web-component-wrapper:  1.2.0
    eslint-plugin-vue: ^6.1.2 => 6.1.2
    eslint-plugin-vue-scoped-css: ^0.3.4 => 0.3.4
    vue: ^2.6.10 => 2.6.11
    vue-cli-plugin-vuetify: ^2.0.3 => 2.0.3
    vue-cli-webpack:  1.0.0
    vue-eslint-parser:  7.0.0
    vue-fontawesome: 0.0.2 => 0.0.2
    vue-hot-reload-api:  2.3.4
    vue-loader:  15.8.3
    vue-router: ^3.1.3 => 3.1.3
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.6.10 => 2.6.11
    vue-template-es2015-compiler:  1.9.1
    vuetify: ^2.2.3 => 2.2.3
    vuetify-loader: ^1.3.0 => 1.4.3
    vuex: ^3.1.2 => 3.1.2
    vuex-persistedstate: ^2.7.1 => 2.7.1
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

Setup your vue.config.js to load the css:

'use strict'

module.exports = {
  transpileDependencies: [
    'vuetify'
  ],
  css: {
    loaderOptions: {
      scss: {
        prependData: '@import "@/scss/app.scss";'
      }
    }
  }
}

What is expected?

You would expect that the app.scss SCSS file would be loaded in every vue component, always.

What is actually happening?

The app.scss SCSS file is only loaded into the component if and only if the component has a non-empty style tag as shown below:

<style lang="scss" scoped>
 /* Cannot have an empty style scoped else app.scss is not imported */
</style>

If the component doesn't have this non-empty style tag, then the SCSS is not loaded.


When over the documentation and search online but I couldn't find a solution to this. While the problem is not critical, it would be nice to have an option that guarantee that the SCSS file would be loaded to every component regardless if the component has or not a non-empty style tag.

Thank you for you time.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions