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.

Problem when importing font from Google in app.scss when running "npm run production"

See original GitHub issue
  • Laravel Mix Version: laravel-mix@0.8.9
  • Node Version v6.9.1
  • NPM Version 3.10.8
  • OS: macOS Sierra

Description:

When run npm run production, sass and js are successfuly mixed and versioned, but when open a browser window i get error: Uncaught SyntaxError: Invalid or unexpected token And here is the line of error: @import url(https://fonts.googleapis.com/css?family=Gloria+Hallelujah|Josefin+Sans);/*! b… etc etc…

From steps to reproduce below : If i remove google font, still fail on first line. If i leave google font, again fail on first line. If i remove all of lines and put only body{ color: red;} fail on first line.

Steps To Reproduce:

Added this line in app.scss:

@import url(https://fonts.googleapis.com/css?family=Gloria+Hallelujah|Josefin+Sans); @import “~bulma”; @import “~font-awesome/css/font-awesome”;

Added this in webpack.mix.js

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css/app.css');
if (mix.config.inProduction) {
    mix.version();
}

from terminal i run: npm run production

output:

DONE  Compiled successfully in 12612ms
Asset       Size  Chunks                    Chunk Names
fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713     166 kB          [emitted]
fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde     444 kB          [emitted]  [big]  
fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9     166 kB          [emitted]
fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad      98 kB          [emitted]
fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e    77.2 kB          [emitted] 
/js/app.609d37602d04c4b9d29f.js     186 kB       0  [emitted]         /js/app
/css/app.579bbe648b1f3671cc67.css     130 kB       0  [emitted]         /js/app
mix-manifest.json  108 bytes          [emitted]         

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
nezaboravicommented, Mar 24, 2017

ahhhh! thanks mate!!!

1reaction
ankurk91commented, Mar 24, 2017

@nezaboravi I am 100% sure that you are including css via script tag like this ->

<!-- Wrong way to include styles -->
<script src="{{ mix('build/css/app.min.css') }}"></script>

I was able re-produce your error, see screenshot - screenshot from 2017-03-24 08-59-39

How to fix this?

<link href="{{ mix('build/css/app.min.css') }}" rel="stylesheet">
Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem when importing font from Google in app.scss ... - GitHub
Problem when importing font from Google in app.scss when running "npm ... When run npm run production, sass and js are successfuly mixed...
Read more >
Problem when importing css from Google in app.scss when ...
When I run "npm run dev", it works fine .. no problem. However, when I run "npm run production", this error appears and...
Read more >
Laravel Mix LESS compilation fails at Google Font import
mix.less('resources/less/app.less', 'public/css/');. Then try running your npm command npm run dev , npm run watch or npm run prod.
Read more >
Loading Fonts with webpack - Chris Courses
If you're currently using webpack to manage your CSS, importing font files won't work without a little bit of extra configuration.
Read more >
Just-in-Time Mode - Tailwind CSS
Tailwind CSS v2.1 introduces a new just-in-time compiler for Tailwind CSS that generates your styles on-demand as you author your templates instead of ......
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