Tho*_* Vo 2 webpack angular-universal angular
我正在尝试为我的 Angular 5 应用程序部署 Angular Universal(最近从 Angular 4 迁移),并且遇到了服务器端渲染选项的问题:
ng build --aot --app 1
Run Code Online (Sandbox Code Playgroud)
我的 scss 文件中的变量路径在客户端有效,但在服务器端渲染命令无效。我收到这样的错误bootstrap-sass
File to import not found or unreadable: bootstrap/variable.
Run Code Online (Sandbox Code Playgroud)
将路径更改为node_modules工作中包的特定路径:
@import '~bootstrap-sass/assets/stylesheets/bootstrap/variables';
Run Code Online (Sandbox Code Playgroud)
我需要修改大约 50 个包含的文件bootstrap/variable,但它仍然被接受。但我的代码还包含一个特定的 scss 文件,并且它因组件而异,如下所示:
@import 'supergazol/footer';
Run Code Online (Sandbox Code Playgroud)
我可以浏览大约 50 个文件来相应地更改它的路径,但这不是很有效且耗时。有没有办法告诉Webpack找到正确的路径?
我对该路径的 Angular CLI 配置不起作用:
"stylePreprocessorOptions": {
"includePaths": [
"../node_modules/bootstrap-sass/assets/stylesheets",
"../src/style/supergazol",
"../src/style"
]
},
Run Code Online (Sandbox Code Playgroud)
文件夹结构:
src
app
assets
environments
style
Run Code Online (Sandbox Code Playgroud)
试试这个,可能会有所帮助。我认为您需要在 .angular-cli.json 文件中的两个应用程序中都包含它(对于客户端和服务器应用程序)。
"stylePreprocessorOptions": {
"includePaths": [
"../node_modules/bootstrap-sass/assets/stylesheets",
"/style/supergazol",
"style"
]
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1078 次 |
| 最近记录: |