Error: quot;You may need an additional loader to handle the result of these loaders.quot;(错误:您可能需要额外的加载器来处理这些加载器的结果。q;)
本文介绍了错误:您可能需要额外的加载器来处理这些加载器的结果。&q;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在和Vue.js和webpack一起开发一个网页。当我在单个文件组件Curry.vue
中编写样式时,构建失败。
<template>
<div>
</div>
</template>
<script>
export default {
}
</script>
<style scoped>
.tomato {
color: red;
}
</style>
错误消息为:
ERROR in ./src/components/Curry.vue?vue&type=style&index=0&id=4d934a99&scoped=true&lang=css& (./node_modules/vuetify-loader/lib/loader.js??ref--7-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Curry.vue?vue&type=style&index=0&id=4d934a99&scoped=true&lang=css&) 12:0
Module parse failed: Unexpected token (12:0)
File was processed with these loaders:
* ./node_modules/vuetify-loader/lib/loader.js
* ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|
|
> .tomato {
| color: red;
| }
@ ./src/components/Curry.vue?vue&type=style&index=0&id=4d934a99&scoped=true&lang=css& 1:0-209 1:225-228 1:230-436 1:230-436
@ ./src/components/Curry.vue
@ ./src/index.js
webpack.config.js
为:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin')
module.exports = {
mode: 'development',
entry: path.join(__dirname, 'src', 'index'),
watch: true,
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/dist/',
filename: "bundle.js",
chunkFilename: '[name].js'
},
plugins:[
new HtmlWebpackPlugin({
template: './src/index.html'
}),
new VueLoaderPlugin(),
new VuetifyLoaderPlugin()
],
module: {
rules: [
{
test:/.vue$/,
use:['vue-loader']
},
{
test: /.jsx?$/,
include: [
path.resolve(__dirname, 'src')
],
exclude: [
path.resolve(__dirname, 'node_modules')
],
loader: 'babel-loader',
query: {
presets: [
["@babel/env", {
"targets": {
"browsers": "last 2 chrome versions"
}
}]
]
}
},
{
test: /.s(c|a)ss$/,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'sass-loader',
// Requires sass-loader@^7.0.0
options: {
implementation: require('sass'),
fiber: require('fibers'),
indentedSyntax: true // optional
},
// Requires sass-loader@^8.0.0
options: {
implementation: require('sass'),
sassOptions: {
fiber: require('fibers'),
indentedSyntax: true // optional
},
},
},
],
},
]
},
resolve: {
extensions: ['.json', '.js', '.jsx', '.vue'],
alias:{
'@': path.resolve('src'),
}
},
devtool: 'source-map',
devServer: {
contentBase: path.join(__dirname, '/dist/'),
inline: true,
host: 'localhost',
port: 8080,
}
};
推荐答案
您需要为css添加规则,您当前的scss规则不适用于css。
只需为CSS添加其他规则:
// webpack.config.js
module.exports = {
...
module: {
rules: [
...
{
test: /.css$/,
use: [
'vue-style-loader',
'css-loader',
]
}
...
]
...
};
这篇关于错误:您可能需要额外的加载器来处理这些加载器的结果。&q;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:错误:您可能需要额外的加载器来处理这些加载器的结果。&q;
猜你喜欢
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Fetch API 如何获取响应体? 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06