Module parse failed: Unexpected character '�' (1:0)
See original GitHub issueI’m getthing this error for both dev & prod builds, for all image file types:
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
I’ve tried reinstalling dependency packages. Also tried to configure next config with and without next-compose-plugins
but same result. My current config:
const webpack = require('webpack');
const sass = require('@zeit/next-sass');
const CSS = require('@zeit/next-css')
const withPlugins = require('next-compose-plugins');
const optimizedImages = require('next-optimized-images');
const fonts = require('next-fonts');
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const nextConfig = {
serverRuntimeConfig: { // Will only be available on the server side
},
publicRuntimeConfig: { // Will be available on both server and client
DOMAIN: process.env.NODE_ENV == 'production' ? 'https://www.example.com/wordpress/index.php' : 'http://example.dev',
}
}
module.exports = withPlugins([
[optimizedImages, {
optimizeImagesInDev: true
}
],
[sass({
webpack(config, options) {
config.module.rules.push({
test: /\.(raw)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: 'raw-loader',
});
if (config.mode === 'production') {
if (Array.isArray(config.optimization.minimizer)) {
config.optimization.minimizer.push(new OptimizeCSSAssetsPlugin({}));
}
}
return config;
}
})],
[CSS],
[fonts]
// your other plugins here
], nextConfig);
Issue Analytics
- State:
- Created 4 years ago
- Comments:14
Top Results From Across the Web
Webpack 4 - Module parse failed: Unexpected character '@'
It's now throwing an error: Module parse failed: Unexpected character '@' You may need an appropriate loader to handle this file type.
Read more >Does not resolve @import. Module parse failed: Unexpected ...
The loader can't resolve @imports, throws error. Config file is just fine, but sass-loader throws errors anyhow: ERROR in .
Read more >Can't build with webpack - Material Design for Bootstrap
css 1:0 Module parse failed: Unexpected character '@' (1:0) You may need an appropriate loader to handle this file type, currently no loaders...
Read more >Module parse failed: Unexpected character ' ' (1:0) You may ...
[Solved]-Module parse failed: Unexpected character ' ' (1:0) You may need an appropriate loader to handle this file type-Reactjs · Related Query ·...
Read more >Import css module - sage - Roots Discourse
yarn dev yarn run v1.22.17 $ bud dev ✘ Module parse failed: Unexpected character '@' (13:0) You may need an appropriate loader to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@geochanto I was! I still get the warnings in dev but no warnings in prod anymore. In my case too I was getting a
not found
error message for the optimized assets but I think it got fixed after I deletedpackage-lock.json
and thenode-modules
folder and re-installed everything but I think you already tried that too right?In case it helps here’s my next config now:
Just narrowed down what’s works vs what doesn’t. Looks like I start getting this error when I add config options.
This doesn’t work:
This works: