[英]not found the scss file when using styling in angular
i want to use the styling in angular for short address in scss files.我想使用 angular 中的样式作为 scss 文件中的短地址。
i using the styling by this way:我通过这种方式使用样式:
i create a folder in the src
folder and put the style on that:我在
src
文件夹中创建一个文件夹并将样式放在上面:
and i go to angular-cli.json
and i add this:和我 go 到
angular-cli.json
我添加这个:
"stylePreprocessorOptions": {
"includePaths": [
"src",
"src/stylings/",
"src/stylings/base/",
"src/stylings/kt-customs/"
]
},
and i need to use that in the style.css
like this way:我需要像这样在
style.css
中使用它:
@import "custom-form";
@import "custom-buttons";
@import "custom-table";
@import "custom-filter";
@import "kt-customise";
but it show me this error:但它告诉我这个错误:
> ERROR in./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js.?/node_modules/postcss-loader/src?.embedded.?/node_modules/sass-loader/dist/cjs?js.?ref--13-3?./node_modules/postcss-loader/src.?postcss?./node_modules/sass-loader/dist/cjs.js..ref--17-1::/src/styles.scss) Module build failed (from;/node_modules/sass-loader/dist/cjs:js). > 错误在./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js.?/node_modules/postcss-loader/ src?.embedded.?/node_modules/sass-loader/dist/cjs?js.?ref--13-3?./node_modules/postcss-loader/src.?postcss?./node_modules/sass-loader/dist/ cjs.js..ref--17-1::/src/styles.scss) 模块构建失败(来自;/node_modules/sass-loader/dist/cjs:js)。 SassError: Can't find stylesheet to import.
SassError:找不到要导入的样式表。 ╷ 9 │ @import "custom-form";
╷ 9 │ @import "自定义表单"; │ ^^^^^^^^^^^^^ ╵ E:\MyProject\Ava\PFA\demo\src\styles.scss 9:9 root stylesheet
│ ^^^^^^^^^^^^^ ╵ E:\MyProject\Ava\PFA\demo\src\styles.scss 9:9 根样式表
how can i solve this problem????我怎么解决这个问题????
I think the import paths you are using in your style.scss
are wrong.我认为您在
style.scss
中使用的导入路径是错误的。 It should be:它应该是:
@import "./stylings/custom-form";
@import "./stylings/custom-buttons";
@import "./stylings/custom-table";
@import "./stylings/custom-filter";
@import "./stylings/kt-customise";
You may want to consider changing your scss
files into scss partials files.您可能需要考虑将您的
scss
文件更改为 scss 部分文件。 That is, renaming both your scss
files and your imports with a leading underscore.也就是说,使用前导下划线重命名
scss
文件和导入。 eg _custom-form.scss
.例如
_custom-form.scss
。
Individual scss
files are transpiled into individual css
files.单独的
scss
文件被转换成单独的css
文件。 Each @import
in a css file creates a HTTP request. css 文件中的每个
@import
都会创建一个 HTTP 请求。 Which means more css files = more HTTP requests.这意味着更多的 css 文件 = 更多的 HTTP 请求。 Importing partials will result in fewer
css
files, and hence, fewer HTTP requests.导入部分将导致更少的
css
文件,因此,更少的 HTTP 请求。 You may read more on partials here: SASS Partials .您可以在此处阅读有关部分的更多信息: SASS Partials 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.