Laravel-mix: Use both Sass and Stylus

Created on 28 Aug 2017  路  4Comments  路  Source: JeffreyWay/laravel-mix

Hello, laravel-mix compiles either Sass or Stylus, is there any way to compile both?

//compiles only Stylus

mix.js('resources/assets/js/app.js', 'public/js')
  .sass('resources/assets/sass/app.scss', 'public/css')
  .stylus('resources/assets/stylus/app.styl', 'public/css', {
    use: [
      require('rupture')()
    ]
  });
//compiles only Sass

mix.js('resources/assets/js/app.js', 'public/js')
  .stylus('resources/assets/stylus/app.styl', 'public/css', {
    use: [
      require('rupture')()
    ]
  })
.sass('resources/assets/sass/app.scss', 'public/css');
stale

Most helpful comment

This is not an issue, as it is not compiling "either sass or stylus", it is simply compiling the first stylesheet you specify, and then the second, and since you don't have any output name specified, it is overwriting the default app.css file that was generated from whichever stylesheet compiled first, so it looks like it has only compiled one of the stylesheets. My suggestion would be to compile both to different names, then use the styles method to concatenate both of the compiled stylesheets:

mix.sass('resources/assets/sass/app.scss', 'public/css/sass.css')
   .stylus('resources/assets/sass/app.styl', 'public/css/stylus.css')
   .styles(['public/css/sass.css', 'public/css/stylus.css'])

That should create an app.css stylesheet that contains both the scss and stylus stylesheets combined.

This may have been a misunderstanding, but in the future, if your question isn't explicitly about an issue with Laravel Mix, you should try asking your question on StackOverflow or the Laracast forum's before opening an actual issue. Thanks!

All 4 comments

 WARNING  Compiled with 1 warnings                  17:56:07                           

 warning  in ./resources/assets/sass/app.scss

(Emitted value instead of an instance of Error)

 鈿狅笍  PostCSS Loader

Previous source map found, but options.sourceMap isn't set.
In this case the loader will discard the source map entirely for performance reasons.
See https://github.com/postcss/postcss-loader#sourcemap for more information.



 @ ./resources/assets/sass/app.scss 4:14-266
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss ./resources/assets/stylus/app.styl
  "devDependencies": {
    "axios": "^0.16.2",
    "laravel-mix": "^1.4",
    "vue": "^2.4.2"
  },
  "dependencies": {
    "browser-sync": "^2.18.13",
    "browser-sync-webpack-plugin": "^1.2.0",
    "font-awesome": "^4.7.0",
    "material-design-icons": "^3.0.1",
    "postcss-css-variables": "^0.8.0",
    "postcss-loader": "^2.0.6",
    "rupture": "^0.6.2",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.1",
    "vuetify": "^0.15.0-beta.2"
  }

This is not an issue, as it is not compiling "either sass or stylus", it is simply compiling the first stylesheet you specify, and then the second, and since you don't have any output name specified, it is overwriting the default app.css file that was generated from whichever stylesheet compiled first, so it looks like it has only compiled one of the stylesheets. My suggestion would be to compile both to different names, then use the styles method to concatenate both of the compiled stylesheets:

mix.sass('resources/assets/sass/app.scss', 'public/css/sass.css')
   .stylus('resources/assets/sass/app.styl', 'public/css/stylus.css')
   .styles(['public/css/sass.css', 'public/css/stylus.css'])

That should create an app.css stylesheet that contains both the scss and stylus stylesheets combined.

This may have been a misunderstanding, but in the future, if your question isn't explicitly about an issue with Laravel Mix, you should try asking your question on StackOverflow or the Laracast forum's before opening an actual issue. Thanks!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dtheb picture dtheb  路  3Comments

rlewkowicz picture rlewkowicz  路  3Comments

mstralka picture mstralka  路  3Comments

pixieaka picture pixieaka  路  3Comments

Bomavi picture Bomavi  路  3Comments