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.

Compiling the same SCSS asset twice with two different node-sass options?

See original GitHub issue

I am trying to compile an asset in two different ways, with two different configurations.

Example:

mix.sass('path/to/same/file.scss', 'public/css/1.css', {
  importer: [
    function1
  ]
});
mix.sass('path/to/same/file.scss', 'public/css/2.css', {
  importer: [
    function2
  ]
});

The options you see above are passed to node-sass which compiles the sass, and the importer option can be detailed on their project page here. I can confirm that this has worked as expected once, and only becomes an issue when I attempt to do the above scenario compiling the same file.

With the following actual function calls:

mix.js(["resources/assets/js/app.js","resources/assets/js/vendor/core/core.js"],'public/js/app.js');
mix.copy("node_modules/winstrap/dist/fonts", 'public/fonts')
mix.sass('resources/assets/sass/app.scss', 'public/css/app.css', { ... });
mix.sass('resources/assets/sass/app.scss', 'public/css/red.css', { ... });

I am getting the following very verbose error that talks a lot about JS, but I know for a fact that this issue is with SCSS because it is only apparent when I run the code relating to SCSS:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.entry should be one of these:
   object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function
   The entry point(s) of the compilation.
   Details:
    * configuration.entry['\js\app'] should be a string.
    * configuration.entry['\js\app'] should NOT have duplicate items (items ## 2 and 3 are identical) ({
        "keyword": "uniqueItems",
        "dataPath": ".entry['\\js\\app']",
        "schemaPath": "#/definitions/common.nonEmptyArrayOfUniqueStringValues/uniqueItems",
        "params": {
          "i": 3,
          "j": 2
        },
        "message": "should NOT have duplicate items (items ## 2 and 3 are identical)",
        "schema": true,
        "parentSchema": {
          "items": {
            "minLength": 1,
            "type": "string"
          },
          "minItems": 1,
          "type": "array",
          "uniqueItems": true
        },
        "data": [
          "C:\\Users\\{username}\\Documents\\{project_name}\\resources\\assets\\js\\app.js",
          "C:\\Users\\{username}\\Documents\\{project_name}\\resources\\assets\\js\\vendor\\core\\core.js",
          "C:\\Users\\{username}\\Documents\\{project_name}\\resources\\assets\\sass\\app.scss",
          "C:\\Users\\{username}\\Documents\\{project_name}\\resources\\assets\\sass\\app.scss"
        ]
      }).
      [non-empty string]
    * configuration.entry['\js\app'] should be one of these:
      non-empty string | [non-empty string]
    * configuration.entry should be a string.
    * configuration.entry should be an array:
      [non-empty string]
    * configuration.entry should be an instance of function
      function returning an entry object or a promise..
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_module
s/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\{username}\AppData\Roaming\npm-cache\_logs\2017-06-21T23_42_34_644Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\{username}\AppData\Roaming\npm-cache\_logs\2017-06-21T23_42_34_877Z-debug.log

Why is this occurring, and how can I accomplish my goal?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

1reaction
weaversam8commented, Oct 14, 2018

@KaiFuglem Wow, this was quite a while ago. I don’t remember my solution, but I’m willing to bet I ended up building a custom Webpack configuration to do it… The webpack documentation is pretty good, so I’m sure there’s a way to do it the way you want.

0reactions
KaiFuglemcommented, Jul 20, 2018

@weaversam8 did you ever find a solution to this issue? …I’m in the same boat as you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compiling the same SCSS asset twice with two different node ...
I am trying to compile an asset in two different ways, with two different configurations. Example: mix.sass('path/to/same/file.scss' ...
Read more >
Error: 'node-sass' version 5.0.0 is incompatible with ^4.0.0
It throws an error: Failed to compile. ./src/App.scss (./node_modules/css-loader/dist/ ...
Read more >
Webpack: compile SASS in own file with multiple entry points
Webpack allows specifying multiple entry points, for example, to compile multiple JavaScript files via Babel. This post shows how to compile ...
Read more >
Stop using an extension to compile Sass - YouTube
NodeJS : https:// nodejs.org ✓ The working Live Sass Compiler ... the script for assets and to get it working on Windows #...
Read more >
Watch & Compile your Sass with npm. | by Brian Han | Medium
css file and you'll see that node-sass indeed compiled your scss file to css. Awesome! Watch the Sass. Let's update our scripts with...
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