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.

Output path issue with mix.sass()

See original GitHub issue

Hi,

I started using this a few days ago on a Node project, works perfectly fine with Vue!

But today I wanted to work a bit on styling and I do encounter an issue with the .sass() method.

Here’s my config used in webpack.mix.js:

mix.js('resources/js/app.js', 'public/app.js')
    .sass('resources/sass/app.scss', 'public/app.css')

And here’s the output of the terminal when running npm run dev or npm run webpack:

Chunk Names
  fonts/glyphicons-halflings-regular.eot?f4769f9bdb7466be65088239c12046d1  20.1 kB     [emitted]
  fonts/glyphicons-halflings-regular.svg?89889688147bd7575d6327160d64e760   109 kB     [emitted]
  fonts/glyphicons-halflings-regular.ttf?e18bbf611f2a2e43afc071aa2f4e1512  45.4 kB     [emitted]
 fonts/glyphicons-halflings-regular.woff?fa2772327f55d8198301fdb8bcfc8158  23.4 kB     [emitted]
fonts/glyphicons-halflings-regular.woff2?448c34a56d699c29117adc64c43affeb    18 kB     [emitted]
                                                            public/app.js   344 kB  0  [emitted]  app
                                                                 /app.css   688 kB  0  [emitted]  app

As you can see, the JS output is fine, it’s where it should be, but the CSS file is put at the root folder of my project.

I’m using bootstrap-sass, so it looks that it is automatically moving the fonts, but again they should go into the public folder, but I don’t really know how I can configure that.

My app.scss file is currently importing bootstrap-sass, and there’s a single class in it:

@import "../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

.top-spacing {
    margin-top: 10px;
}

It seems that the specified output path is truncated, because I gave it a try by using public/public/app.css, and it actually works!

Just in case, here’s my directory structure:

- node_modules
- public
- resources
    - js
        app.js
    - sass
        app.scss
webpack.config.js
webpack.mix.js

Thanks in forward for your help, I’m also looking into the code to see what could be the issue, but no success so far!

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
JeffreyWaycommented, Dec 29, 2016

For Node apps, you’ll have to tell Mix where your public directory is. Add this, and it should work:

mix.js('resources/js/app.js', 'public/')
   .sass('resources/sass/app.scss', 'public/')
   .setPublicPath('public');
0reactions
monorigaborcommented, Dec 29, 2016

Awesome, works perfectly! Thanks for your very quick reaction!

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Laravel-mix output path is outputting two different ...
mix file exists, so I had to do some changes first: Inside 'node_modules/laravel-mix/src/Paths.js' I changed the mix() function like this:
Read more >
Sass processing path won't resolve outside of public path #2757
Successfully merging a pull request may close this issue. Allows relative output paths to be used for sass calls jeremy-smith-maco/laravel-mix.
Read more >
CSS Preprocessors | Laravel Mix Documentation
sass() (or any of the preprocessor variants) as many as times as is needed. For each call, webpack will output a new file...
Read more >
How to use the laravel-mix.setPublicPath function in ... - Snyk
By default, we are compiling the Sass | file for the application as well as bundling up all the JS files. | */...
Read more >
Compiling Assets (Mix) - The PHP Framework For Web Artisans
You may compile multiple Sass files into their own respective CSS files and even customize the output directory of the resulting CSS by...
Read more >

github_iconTop Related Medium Post

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