-
-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.../styles.css Unexpected character '@' #355
Comments
I am getting the same issue as well. Build runs fine with no "@charset" present. |
Same issue with |
same issue with @import "~quill/dist/quill.snow.css"; |
Anyone figure out the issue here? I'm seeing the same thing with |
I got the same issue with @font-face |
@iceleaf97 couldn't get it to work with your suggestion. |
Same issue here with @charset. It seems I only have this issue in Webpack 2, not Webpack 1. |
Same issue here. Extra '@' character comes from a third-party lib so I'm thoroughly stuck with this bug. |
same issue trying to load 'element-ui' css |
can someone create a repository where the bug is reproduceable? just tried it myself and cant reproduce. |
same issue with @Keyframes |
Same issue with mint-ui and Laravel Mix: ERROR in ./~/mint-ui/lib/cell/style.css
Module parse failed: /Users/name/Code/project/node_modules/mint-ui/lib/cell/style.css Unexpected token (10:0)
You may need an appropriate loader to handle this file type.
| /* Radio Component */
| /* z-index */
| .mint-cell { ERROR in ./~/mint-ui/lib/font/style.css
Module parse failed: /Users/name/Code/project/node_modules/mint-ui/lib/font/style.css Unexpected character '@' (2:0)
You may need an appropriate loader to handle this file type.
|
| @font-face {font-family: "mintui";
| src: url(data:application/x-font-ttf;base64,AAEAAAAPAIAAAwB… |
can anyone here provide a reproducable example? :) |
@timse not pretty sure if it is a
In my entry point is
My package.json
|
@timse, all I made some progress. I noticed that the So I added the following lines and the error gone
Now the assets are bundled just fine |
I'm new to Webpack and didn't get what the error cause was for hours… Later I found it was lacking the CSS loader and the snippet bellow fixed the issue for me: // webpack.mix.js
const { mix } = require('laravel-mix');
mix.webpackConfig({
module: {
rules: [
{
test: /\.css$/,
loader: 'style-loader!css-loader'
}
]
}
})
mix.js('resources/assets/js/main.js', 'public/js')
.sass('resources/assets/sass/main.scss', 'public/css'); In my case I didn't modify the Webpack config directly, instead I extended Laravel Mix configuration. To use Mint UI I also had to install the npm install babel-plugin-component --save-dev // .babelrc
{
"plugins": [["component", [
{
"libraryName": "mint-ui",
"style": true
}
]]]
} |
@timse reproduced here https://github.com/jrood/unexpected-char-bug-reproduced |
I am seeing something similar I have the following in a less file..
And I get
My webpack config looks like this...
|
@jrood if i remove this line: it works |
Oh my, it was that slash in the path wasn't it. Thanks @timse |
not sure, but i guess the reason this appears to be a problem is, that its at the top of the file so it looks like it has something to do with hope that fixes it for you |
oh and try to update to the latest version of this extract-text-plugin |
If your dependency grap isn't to complex, you could do that yes, the reason to load them and moved them to File Tree (Grunt, Gulp)
Dependency Graph (webpack)
You will get this all the time, when storing them in one place :) import foo from '../../../component' className {
background-image: url('../../../image.png')
} Thats why |
@michael-ciniawsky you're killing me now as I spent 8h on this already :) It's a Drupal (php CMS) website, so definitely not component based architecture - and yes now all the problems make sense.. |
@evilebottnawi I didn't get how to completely ignore fonts and images ; essentially there's no "src" and "dist" for my images as I've already included them in the "dist" directory.. this codebase I'm working on doesn't have a clear separation between src and dist (although I could make it now..) |
so what happens now is webpack is generating a |
@gkatsanos I'm not too familiar with with |
@gkatsanos also try to search in google |
Maybe if JS only, better take a look at Rollup first and just ES2015 modulize the JS as a starting point :), it's not necessary to utilize webpack here if the architecture doesn't match (best/easiest example for getting started would be a simple react app). Gulp and webpack are similar in terms of 'you can build your stuff from start to finish' but that's also where the similarity ends 😛 . The concepts are enterily different approaches File Directory (File Tree) vs. Dependency Graph (parse, walk && resolve the |
- { test: /\.(jpg|png|woff|woff2|eot|ttf|svg)$/, loader: 'file-loader?limit=100000' }
|
The CMS in use isn't important 🙃 It's about the front-end architecture. Serving a |
I totally understand. I've built 1-2 SPA's with Vue / Webpack so I've used the Component Based Architecture. Although I must say there are often times you need a concept of "Page" rather than a "Component" so I'm not sure if everything can be a Component in that sense.. Anyway. now I'm left with my half-baked webpack config and don't know how to proceed and if I should just stash and go back to Gulp. There is no concept of components in Drupal, so I will have to output all JS and CSS in the same directory by webpack's philosophy right? |
Your bundle is the/a 'page' + an initial 'index.html'. The rest is client-side routing 😛 and AJAX to get the data (state) from the back-end. You never leave the |
It highly depends on how in particular your current page looks like, that's something you need to figure out yourself 🙃 , I didn't meant to discourage you on anything, try it out 😛, but it can cause you more trouble in the end by 'blindly' trying to press that into something 'webpack-able' |
:) but my website isn't a JS-generated thing - JS is only for effects:carousels/dropdowns/lazy loads etc, so indeed following the dependency tree of .js files doesn't do much.. |
See e.g Drupal more as an API in a SPA, it's likely to be the case that many of the CMS 'Management' (PHP- based on a classical Request/Response Circle pattern) funtionality is obsolete then :D |
Browserify is just fine for that and if you want to use ES2015 Modules Syntax then better Browserify => Rollup (gulp-rollup) page.js (with Rollup) import $ from 'jquery'
import { carousel, effect1, ... } from './lib/animations'
... |
great. last question. if my images are supposed to live in components, and I have already separated them by folder / page ; why is webpack dumping them all in the same directory ignoring the original path? |
It rewrites the paths in various (loaders, plugins) places and finally adds them to the destination set in |
works :) I'm stubborn :) at least if I make a bare-bones working prototype then I can think on what's the best way to go about this. THanks for all the tips! |
It's gathering them so the speak, the same applies to some point for CSS in conjunction with ETWP, webpack gathers the CSS chunks and emits a file, not useful when there are not a bunch of relative components, most of the time you will always to something like components/component/index.js import style from './index.css'
import icon from './image.png'
import component from './subcomponents/component'
.... components/component/subcomponents/component/index.js import style from './index.css'
import icon from './image.png'
import component from './subcomponents/component'
.... |
Which gets 'flattened' in the |
/cc @michael-ciniawsky i think we can close this issue, seems invalid configuration (majority) and invalid usage some loaders (less) and invalid If someone else will face the problem simply create a new issue, be good disable to commenting here 😄 |
@evilebottnawi @michael-ciniawsky I have to say one thing that helped me which maybe should be stressed more in the documentation section : "if you're coming from gulp". The point is this : |
@gkatsanos What about me then I went from |
I also meet this error,but it's for .png, here is: {
test: /\.(jpe?g|png|gif|svg)$/i,
use: [
{
loader: 'file-loader',
options: {
name: 'imgs/[name].[ext]'
},
options: {
},
}, {
loader: 'image-webpack-loader',
options: {
gifsicle: {
interlaced: false,
},
optipng: {
optimizationLevel: 7,
},
pngquant: {
quality: "65-90",
speed: 4
},
mozjpeg: {
progressive: true,
quality: 65
},
svgo: {
plugins: [
{
removeViewBox: false
},
{
removeEmptyAttrs: false
}
]
}
}
}
],
include: path.join(rootPath, 'src/imgs/**/*'),
exclude: [/node_modules/, path.join('imgs/sprites')]
} .less file: .product-card-inner{
width: 100%;
height: 100%;
position: relative;
background: url(../imgs/card-bg.png) no-repeat;
background-size: auto;
background-position: center;
} and i got error like this: ERROR in ./src/imgs/card-bg.png
Module parse failed: /Users/chw/fecode/installment-fe/src/imgs/card-bg.png Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
@ ./~/css-loader?{"modules":false,"minimize":false,"sourceMap":true,"camelCase":false}!./~/postcss-loader?{}!./~/less-loader/dist?{"sourceMap":true}!./src/less/product.less 6:425-455 someone can tell me why? |
same question {
test: /\.css$/,
use: CSSExtractor.extract({
use: [{
loader: "css-loader"
}, {
loader: "postcss-loader"
}]
})
} @font-face {
font-family: 'evc';
src: url('../fonts/evc.eot') format('embedded-opentype');
src: url('../fonts/evc.svg') format('svg');
src: url('../fonts/evc.ttf') format('truetype');
src: url('../fonts/evc.woff') format('woff');
} |
if anyone still need help with this,
and I had to install devDependencies like that worked. |
A lot of problems here happen due invalid configuration. Closing issue. Please create new issue with minimum reproducible test repo. Thanks! |
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
Example style.css
The text was updated successfully, but these errors were encountered: