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.

Modify sass-loader options in webpack.mix.js file

See original GitHub issue

Have any option to modify the sass-loader options in the webpack.mix.js file? I want to import (override) sass variables into my .vue file <style> tags.

For example:

Example.vue:

<template> ... </template>
<script> export default { ... } </script>
<style lang="scss">
/* ---- I want to import ./styles/custom_variables file here ---- */
@import './styles/imports';

$ui-alert-color             : rgba(black, 0.75) !default;
$ui-alert-font-size         : rem-calc(15px) !default;
$ui-alert-margin-bottom     : rem-calc(16px) !default;
</style>

I can modify the webpack.config.js#L165 to:

options:
    Object.assign(
        toCompile.pluginOptions,
        { data: '@import "./styles/custom_variables";' }
    )

But i think it’s not a nice workaround.

Ps: It’s an awesome tool Jeff, keep it up! 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11

github_iconTop GitHub Comments

6reactions
JeffreyWaycommented, Feb 17, 2017

You can pass your plugin options as the third argument to mix.sass(). So I think you should be able to do:

mix.sass('src', 'output', {
    data: '@import "./styles/custom_variables";'
});
3reactions
JonasDoebertincommented, Apr 11, 2017

That doesn’t work for me. The @import from the data option only gets applied to the main app.scss file im processing. Not to the *.vue components imported in the JS.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modify sass-loader options in webpack.mix.js file #411 - GitHub
Have any option to modify the sass-loader options in the webpack.mix.js file? I want to import (override) sass variables into my .vue file....
Read more >
Sass Preprocessing | Laravel Mix Documentation
Let's add Sass compilation to our webpack.mix.js file. ... For a full list of supported options, please refer to the webpack documentation for...
Read more >
sass-loader - webpack - JS.ORG
Loads a Sass/SCSS file and compiles it to CSS. ... Then add the loader to your Webpack configuration. For example: app.js import "./style.scss";....
Read more >
vue.js - Sass Loader issue with Webpack and Laravel Mix 3
I have a project that is using Laravel Mix version 3 (I cannot upgrade because of the known dynamic importing issue with Webpack...
Read more >
Compiling Assets (Mix) - The PHP Framework For Web Artisans
js file is your entry point for all asset compilation. Think of it as a light configuration wrapper around webpack. Mix tasks 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