Closed bosens-China closed 1 month ago
完整配置文件
import { defineConfig, loadEnv } from "@rsbuild/core";
import path from "path";
import { pluginLess } from "@rsbuild/plugin-less";
import { pluginSass } from "@rsbuild/plugin-sass";
import { pluginSvgr } from "@rsbuild/plugin-svgr";
import { pluginBabel } from "@rsbuild/plugin-babel";
import { pluginVue2 } from "@rsbuild/plugin-vue2";
import { pluginVue2Jsx } from "@rsbuild/plugin-vue2-jsx";
import { pluginNodePolyfill } from "@rsbuild/plugin-node-polyfill";
const { publicVars } = loadEnv({ prefixes: ["VUE_APP_"] });
export default defineConfig({
plugins: [
pluginBabel({
include: /\.(?:jsx|tsx)$/,
}),
pluginSvgr(),
pluginVue2(),
pluginVue2Jsx(),
pluginLess({
lessLoaderOptions: {
lessOptions: {
// If you are using less-loader@5 please spread the lessOptions to options directly
modifyVars: {
"primary-color": "#5384FE",
"error-color": "#ED4D37",
"btn-danger-bg": "#ED4D37",
"btn-danger-border": "#ED4D37",
"success-color": "#48BB78",
"text-color": "#4A5568",
"text-color-secondary": "#A0AEC0",
"btn-default-color": "#718096",
"border-color-base": "#CBD5E0",
"input-placeholder-color": "#A0AEC0",
"tooltip-bg": "rgba(26,32,44,.8)",
"heading-color": "#4A5568",
"background-color-base": "#F7F8FA",
},
javascriptEnabled: true,
math: "always",
},
},
}),
pluginSass({
sassLoaderOptions: {
additionalData:
'@import "@/styles/variables.scss";@import "@/styles/mixin.scss";', // @import "@/styles/localIcon.scss";
},
}),
pluginNodePolyfill(),
],
source: {
// 指定入口文件
entry: {
index: "./src/main.js",
},
define: publicVars,
include: [
/node_modules\/transpileDependencies/,
/node_modules\/@antv/,
/node_modules\/antv\/x6/,
/node_modules\/vuex-persist/,
/node_modules\/gm-crypt/,
/node_modules\/sm-crypto/,
],
},
html: {
template: "./public/index.html",
},
tools: {
rspack: {
devtool: "source-map",
resolve: {
extensions: [".vue", ".js", ".jsx", ".tsx", ".ts", ".json"],
alias: {
"@": path.resolve(__dirname, "src"),
},
},
},
},
});
I can't reproduce this issue, can you provide a minimal reproduction?
Hello @bosens-China. Please provide a reproduction repository or online demo. For background, see Why reproductions are required. Thanks ❤️
我创建了一个最小仓库也没这个错误。
但是能给一些建议吗,我不太清楚怎么排查到具体的原因,出现这个报错可能是啥导致的
@chenjiahan 定位到问题了
<template>
<div>hello</div>
</template>
<script>
export default {};
</script>
<style lang="scss" scoped>
// @import "./style.scss";
@import url("~@/layout/style.scss");
</style>
注意上面的import导入就会出现这个问题。 这个是写法的问题,但是我不确定是否需要保留这种不规范写法
建议还是改成规范的 Sass 写法哈 https://sass-lang.com/documentation/at-rules/import/
Version
Details
迁移vuecli项目的过程中,发现scss文件提示这个错误
报错信息
关闭map
提示 File: /Users/yliu/Desktop/job/jcnl-admin/src/styles/index.scss:1:1 × Module build failed: ╰─▶ × Error: HookWebpackError: × Module build failed: │ ╰─▶ × Error: resolve-url-loader: error processing CSS │ │ a valid source-map is not present (ensure preceding loaders output a source-map)
正确做法是什么?
Reproduce link
none
Reproduce Steps
正常输出