如何在 Chrome 开发工具中获取映射 Angular CLI css 文件? [英] How to Source Map Angular CLI css files in Chrome Dev Tools?
问题描述
有没有一种方法可以设置源映射样式,以便在 Chrome 开发工具中所做的编辑可以持久保存到添加的本地工作区?
Chrome Dev Tools 在元素检查器的 <style>...</style>
标签中显示了我在 styles.scss
中的所有样式.
Chrome Dev Tools is showing all my styles in styles.scss
in a <style>...</style>
tag in the element inspector.
我已经设置了 Chrome Dev Tools 工作区,类似于 @vt5491 在他们的 SO 中的做法:https://stackoverflow.com/a/37627935/1762493 并且这适用于 .ts
文件我相信但元素样式不会链接回元素检查中的源映射,因为它们已经构建ng 服务于 index.html
的 元素.
I've setup Chrome Dev Tools workspaces similar to how @vt5491 did it in their SO here: https://stackoverflow.com/a/37627935/1762493 and that is working for the .ts
files I believe but element styles don't link back to source maps in the element inspect as they've been built with ng serve into index.html
's <style>
element it seems.
- 我正在运行
ng serve -dev -p=8081
- 并尝试了
ng serve -dev -p=8081 --aot=true
但得到了ENONET ng.factory.js 丢失错误
- 我尝试在
app.component.css
和styles.scss
中放置样式 - 我用
ng build
尝试了这个,但它也将所有样式放入index.html
的
- I'm running
ng serve -dev -p=8081
- and tried
ng serve -dev -p=8081 --aot=true
but got aENONET ng.factory.js missing error
- I tried putting styles in
app.component.css
versusstyles.scss
- I tried this with
ng build
but it also puts all styles intoindex.html
's<style>
这是目前使用 Angular CLI 的方式吗?也许调整下面的网络包?它似乎为每个编译的样式表添加 标签.如果这就是 CLI 当前的工作方式,那么这可能不仅仅是一个问题,而是一个功能请求,因为我们正在正确地做前端工作,所以让这个工作可以节省时间.
Is this just the way it is currently with the Angular CLI? Maybe tweaking the web-pack underneath? It seems to be adding <style>
tags per compiled stylesheet. If this is how the CLI is working currently then maybe this isn't just a question but a feature request because we are doing front-end work right, so having this working would save time.
相关:
- 如何在 Chrome 开发者工具中将 CSS 样式更改保存到 ANGULAR 2.0 组件表单?
- Angular-cli 不使用 --dev 生成打字稿文件选项
- 如何使用 angular- 调试 angular 2 应用程序cli webpack?(在WebStorm中)
- SCSS SourceMap 仅指向父选择器.
- How to save CSS Style changes to ANGULAR 2.0 components form within Chrome Developer Tools?
- Angular-cli not generating typescript files with --dev option
- How to debug angular 2 app using angular-cli webpack? (in WebStorm)
- SCSS SourceMap pointing to the Parent selector only.
- github.com/angular/angular-cli Issue #2826
感谢您提供的任何建议.
Thanks for any advice offered.
推荐答案
Angular-cli 使用 webpack,但它在/node_modules/angular-cli/models 中有自己的配置文件.
Angular-cli uses webpack, but it comes with its own configuration files in /node_modules/angular-cli/models.
您可以修改它们,但是如果您升级 angular-cli,它将覆盖您的文件.所以一定要备份它们.
You can modify them, but if you upgrade angular-cli it will overwrite your files. So make sure to back them up.
是的,它旨在内联
标签.我同意这看起来很奇怪,应该放在一个单独的文件中,主要是为了用户可以缓存它并减少您的视图块大小.可能是他们认为内联是好的,因为当您处于开发模式时,您不希望它被缓存,这很好,但是在 'ng build' 上,它应该被编译到自己的文件中.
Yes, it is meant to go inline
<style>
tags. I agree that this seems weird and should be in a separate file, mainly so it can be cached by the user and reduce your views chunk size. It might be that they think inline is good as when you're in development mode you don't want it cached, which is fine, but on 'ng build' it should be compiled to its own file.我知道你可以使用extract-text-webpack-plugin"来配置 webpack 来做到这一点,但我对它不太熟悉.
I know you can configure webpack to do that using the "extract-text-webpack-plugin", but I am not too familiar with it.
我希望 angular-cli 在构建时这样做,或者在配置中有一个选项.
I would like to see angular-cli do that on build or have an option in the configuration for that.
这篇关于如何在 Chrome 开发工具中获取映射 Angular CLI css 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!