When i import owl.carousel
I face the below error, What is it exactly, and what can I do for it?
./node_modules/owl.carousel/dist/assets/owl.carousel.css Module build failed (from./node_modules/mini-css-extract-plugin/dist/loader.js): ModuleParseError: Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
webpack.config.js
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const autoprefixer = require("autoprefixer");
const webpack = require("webpack");
module.exports = (env) => {
let clientPath = path.resolve(__dirname, 'src/main/client');
let outputPath = path.resolve(__dirname, (env === 'production') ? 'src/main/resources/static' : 'out')
return {
mode: !env ? 'development' : env,
entry: {
index: ["babel-polyfill", clientPath + '/index.js']
},
output: {
path: outputPath,
filename: '[name].js'
},
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors'
}
}
},
minimizer: (env === 'production') ? [
new UglifyJsPlugin(),
new OptimizeCssAssetsPlugin()
] : []
},
devServer: {
contentBase: outputPath,
publicPath: '/',
host: '0.0.0.0',
port: 8081,
proxy: {
'**': 'http://127.0.0.1:8080'
},
inline: true,
hot: false
},
module: {
rules: [
{
test: /\.js$/,
use: [{
loader: 'babel-loader',
options: {
presets: 'env'
}
}]
},
{
test: /\.(css)$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
{
loader: 'css-loader'
},
{
loader: "postcss-loader",
options: {
plugins: () => {
return [
autoprefixer({
overrideBrowserslist: "cover 99.5%"
})
];
}
}
},
]
},
{
test: /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
name: '[name].[ext]',
outputPath: 'urls/'
}
}
},
{
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'images/'
}
}
}
]
},
plugins: [
new MiniCssExtractPlugin({
path: outputPath,
filename: '[name].css'
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery"
})
]
}
}
Why This Error appear?
ADD
It's happen every file ( also semantic ui )
the strange character you see has to do with the icon's image they have, I'm assuming you have url-loader and file-loader installed but I see that you are using the outputPath
? which I think it's the source of the problem?
Here is a simple configuration that worked for me:
{
test: /\.(png|jpg|gif|svg)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
name: '[name].[hash:7].[ext]'
},
},
],
}
You can copy it or just get rid of the outputPath and see if this solve your issue:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.