Jer*_*ome 5 webpack sass-loader
当我使用 Webpack 别名时,我遇到了 @use 规则的问题。
\n在部分 theme.scss 中,我尝试使用 style.scss 中的 mixin。
\n/src/assets/css/_theme.scss\n/components/UI/Button/_style.scss\n/components/UI/Button/main.tsx\n/components/UI/Radio/_style.scss\n/components/UI/Radio/main.tsx\nRun Code Online (Sandbox Code Playgroud)\n这适用于相对路径:
\n@use '../../components/UI/Button/style' as button;\nRun Code Online (Sandbox Code Playgroud)\n但不能使用如下别名:
\n@use 'Components/UI/Button';\n@use 'Components/UI/Button/style';\nRun Code Online (Sandbox Code Playgroud)\n在第二种情况下,我收到此错误:
\nSassError: SassError: Can't find stylesheet to import.\n1 \xe2\x94\x82 @use 'Components/UI/Button';\nRun Code Online (Sandbox Code Playgroud)\n别名已在 tsconfig.json 中声明
\n"baseUrl": "./",\n"paths": { "Components/*": ["src/components/*/main"] }\nRun Code Online (Sandbox Code Playgroud)\n并在我的 Webpack 配置中使用 TsconfigPathsPlugin :
\nresolve: {\n ...\n plugins: [new TsconfigPathsPlugin()],\n}\nRun Code Online (Sandbox Code Playgroud)\n我在 sass-loader 中没有找到任何用于特定解析的选项。如何在 saas-loader 中使用别名?
\n| 归档时间: |
|
| 查看次数: |
234 次 |
| 最近记录: |