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

Adding an extra options object to sass-loader #4434

Closed
profyt opened this issue Aug 14, 2019 · 9 comments
Closed

Adding an extra options object to sass-loader #4434

profyt opened this issue Aug 14, 2019 · 9 comments
Labels
needs team repro We acknowledged your report and will soon try to reproduce it

Comments

@profyt
Copy link

profyt commented Aug 14, 2019

Version

3.9.3

Environment info

System:
OS: Linux 4.20 Linux Mint 19.1 (Tessa)
CPU: (4) x64 AMD Athlon 200GE with Radeon Vega Graphics
Binaries:
Node: 11.13.0 - ~/.nvm/versions/node/v11.13.0/bin/node
Yarn: Not Found
npm: 6.7.0 - ~/.nvm/versions/node/v11.13.0/bin/npm
Browsers:
Chrome: 75.0.3770.80
Firefox: 67.0
npmGlobalPackages:
@vue/cli: 3.9.3

Steps to reproduce

Add in vue.config.js options for sass-loader.
image

What is expected?

An option with data will be added to the loader options:
{ loader: 'sass-loader', options: { sourceMap: false, ......, data: '@import "~@/variables.scss";' }, }

What is actually happening?

A second options object is created, to which changes are added from vue.config:

{ loader: 'sass-loader', options: { sourceMap: false, ...... }, options: { data: '@import "~@/variables.scss";' }, }

@LinusBorg
Copy link
Member

Please provide a reproduction as is required.

How did you check for the duplicate object?

@LinusBorg LinusBorg added the needs reproduction This issue is missing a minimal runnable reproduction, provided by the author label Aug 14, 2019
@profyt
Copy link
Author

profyt commented Aug 15, 2019

How did you check for the duplicate object?

After changing the configuration, I used vue-cli-service inspect. I found a rule in it for which I made changes and saw a duplication of the options object there.

Here is the repository with the configuration; during inspection, see the sass section, there will be double options everywhere.
https://github.com/profyt/Vue-cli-duplicate-options
-npm i
-vue-cli-service inspect ( to get full config)

@LinusBorg LinusBorg added needs team repro We acknowledged your report and will soon try to reproduce it and removed needs reproduction This issue is missing a minimal runnable reproduction, provided by the author labels Aug 15, 2019
@LinusBorg
Copy link
Member

Thanks, we'll check it out

@sodatea
Copy link
Member

sodatea commented Aug 16, 2019

  css: {
    loaderOptions: {
      sass: {
-        options: {
          data: `@import "~@/variables.scss";`
-        }
      },
    }
  }

The example in our documentation does not have the extra options.
See https://cli.vuejs.org/guide/css.html#passing-options-to-pre-processor-loaders

@sodatea sodatea closed this as completed Aug 16, 2019
@profyt
Copy link
Author

profyt commented Aug 21, 2019

  css: {
    loaderOptions: {
      sass: {
-        options: {
          data: `@import "~@/variables.scss";`
-        }
      },
    }
  }

@sodatea
But this option will not be added to the settings. It will be added after the options object, therefore the configuration will not be working!
https://github.com/webpack-contrib/sass-loader#string

@sodatea
Copy link
Member

sodatea commented Aug 21, 2019

I mean, if you do this, the options will be merged correctly:

  css: {
    loaderOptions: {
      sass: {
        data: `@import "~@/variables.scss";`
      },
    }
  }

@profyt
Copy link
Author

profyt commented Aug 21, 2019

I tried to do as you showed. But as a result, Data is not added to the options, but after them.

@sodatea
Copy link
Member

sodatea commented Aug 21, 2019

It works on my machine after modifying your reproduction repository.
image

@sodatea
Copy link
Member

sodatea commented Aug 21, 2019

The modification I suggested was that this line in your config is extraneous:
https://github.com/profyt/Vue-cli-duplicate-options/blob/7965fceee9d477fd5c304c8fab0395f2457aeb66/vue.config.js#L17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs team repro We acknowledged your report and will soon try to reproduce it
Projects
None yet
Development

No branches or pull requests

3 participants