css-loader: .../styles.css Unexpected character '@'
Hi all! I get something strange error, maybe i did wrote wrong config file. But if the file is styles.css present @charset “UTF-8”, the parser generates an error.
Example index.js
require('./styles.css')
Example style.css
@charset "UTF-8"
body {
...
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 27
- Comments: 67 (27 by maintainers)
@timse, all I made some progress. I noticed that the
webpack.config.js
file that ships with laravel-mix@0.5.16 lacks the test for css files.So I added the following lines and the error gone
Now the assets are bundled just fine
I got the same issue with @font-face Add some code in webpack.config.js file and it does work.
{ test: /(\.css$)/, loaders: ['style-loader', 'css-loader', 'postcss-loader'] }, { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }
same issue trying to load ‘element-ui’ css
Same issue with
@font-face
😕@jrood if i remove this line: https://github.com/jrood/unexpected-char-bug-reproduced/blob/master/webpack.config.js#L19
it works
can anyone here provide a reproducable example? 😃
Same issue here with @charset. It seems I only have this issue in Webpack 2, not Webpack 1.
@timse reproduced here https://github.com/jrood/unexpected-char-bug-reproduced
Same issue with mint-ui and Laravel Mix:
Same issue here. Extra ‘@’ character comes from a third-party lib so I’m thoroughly stuck with this bug.
if anyone still need help with this,
rules: [ { test: /\.(js|jsx)$/, exclude: /node_modules/, loader: 'babel-loader' }, { test: /(\.css$)/, include: /node_modules/, loaders: ['style-loader', 'css-loader'] }, { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' } ]
these are the rules.and I had to install devDependencies like
url-loader
andfile-loader
that worked.
same issue with @import “~quill/dist/quill.snow.css”;
same question
@gkatsanos What about me then I went from
.sh
->grunt
->gulp
->webpack
. I will agree it is diffucult to start thinkingrequire/import
aftermove from source to dest
, but it is related morewebpack
docs then loader, you can create issue about this and help clarify this, example add notemigrate-from-grunt-gulp
, try to describe the basic principles of the work is brief and understandable, perhaps I could help in this, but my native language is not English and it’s all difficult for me 😭Assets need to be loaded via an appropiate loader 😆, you need
url/file-loader
and add a rule tomodule.rules
for each file type (extension)I recommend you use a few simple
.css/.sass
files and test if that works (that == CSS Setup) 😃, nourl()
(Assets) etc. from the start, since resolving the correct asset paths especially as a beginner will bug you many times I swear you that 😛. Use the progressive approach instead and add things step by step to get familiar with the ‘webpack way’UPDATED: I wasn’t using file-loader as it wasn’t included in the angular2-seed webpack starter project I was using. Have now installed file-loader and using it for images and the issue is fixed. Thanks for the heads-up.
No it isn’t. Should it be? I’m not currently using a loader for images. Here is my webpack.config file, effectively what I got with the angular2-seed project with slight amendment to reflect renaming of latest version of angular2-router-loader.
Oh my, it was that slash in the path wasn’t it. Thanks @timse