angular - Angular 通用:找不到或无法读取要导入的文件:~src/main.scss
问题描述
我创建了一个新项目ng new
并运行了以下命令(ref):
ng add @nguniversal/express-engine --clientProject my-project-name
npm run build:ssr && npm run serve:ssr
这启用了端口 4000 上的服务器端渲染。
到目前为止一切都很好。
现在我添加了一个main.scss
. 然后在 中my app.component.scss
,我使用语法导入tilde
如下:
@import "~src/main.scss";
现在运行时npm run build:ssr && npm run serve:ssr
出现以下错误:
ERROR in Module build failed (from ./node_modules/sass-loader/lib/loader.js):
@import "~src/main.scss";
^
File to import not found or unreadable: ~src/main.scss.
in D:\nodebook2\angular-universal-test\src\app\app.component.scss (line 1, column 1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! angular-universal-test@0.0.0 build:client-and-server-bundles: `ng build --prod && ng run angular-universal-test:server:production`
~src
除了用“常规”路径替换之外的任何解决方法?(我有100个组件的项目,全部~src
用于导入scss文件)
解决方案
推荐阅读
- c++ - 常量引用的正确语法
- c# - System.TypeLoadException C# Xamarin
- python - 生成所有可能的 Kakuro 解决方案的字典
- deep-linking - Branch.io initSession 返回空的 BranchUniversalObject JSON 和 BranchLinkProperties JSON
- python - conda和pip的pytorch安装问题
- vba - MS Access 使用 Combo-Box 值作为查询条件
- jquery - jQuery:用于比较各种列表项中的文本的变量
- c++ - 一副牌输出错误
- javascript - jQuery async/await Ajax 调用,没有在 HTTP <> 200 上触发异常?
- swift - swift 11 中的秒表应用程序(编码世界的新手)