gpt4 book ai didi

dart - 为什么Dart Polymer将主CSS文件内联/硫化到标签中?

转载 作者:行者123 更新时间:2023-12-03 03:44:38 25 4
gpt4 key购买 nike

web / templates / ui-elements.html

<polymer-element name="app-element">
<template>
<link rel="stylesheet" href="/main.css"/>
<div class="classes from main-css file"></div>
<content></content>
</template>
<script type="application/dart" src="ui-elements.dart"></script>
</polymer-element>

<polymer-element name="ui-icon" attributes="name" noscript>
<template>
<link rel="stylesheet" href="/main.css"/>
<span class="fa fa-{{name}}"></span>
</template>
</polymer-element>

...

网站/模板/ui-elements.dart

@CustomTag('app-element')
class AppElement extends PolymerElement {
AppElement.created() : super.created();
}

...

网站/main.dart

import 'package:polymer/polymer.dart';

main() {
initPolymer();
}

@whenPolymerReady
void onReady() {
}

web / main.html ( pub build之前的入口文件)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="import" href="templates/ui_elements.html"/>
</head>
<body>
<app-element></app-element>
<script type="application/dart" src="main.dart"></script>
</body>
</html>

web / main.html ( pub build后的进入文件)

<!DOCTYPE html><html lang="en"><head><script src="packages/web_components/webcomponents.min.js"></script><script src="packages/web_components/dart_support.js"></script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<style>
...HERE IS FULL CONTENT OF main.css...
</style>
</head><body>
...
HERE ARE ELEMENTS THAT ALSO USE main.css, so it's also downloading
<polymer-element name="ui-icon" attributes="name" noscript>
<template>
<link rel="stylesheet" href="/main.css"/>
<span class="fa fa-{{name}}"></span>
</template>
</polymer-element>
...

<script src="main.html.polymer.bootstrap.dart.js" async=""></script>
</body></html>

相关问题:
  • 如何避免main.css文件的“内联/ ulcanazing”内容?
  • 为什么创建Polymer这样大的输出文件:main.html.polymer.bootstrap.dart.js(323kb),polymer.min.js(121kb),webcomponents.min.js(103kb)。在不久的将来会有什么变化吗?
  • Polymer还没有自动包含在编译的main.html中的其他文件(请参见屏幕):
  • main.web_components.bootstrap.dart
  • main.dart.js


  • 附加屏幕:

    最佳答案

    您可以在pubspec.yaml文件的Polymer变压器配置中配置此行为,例如

    transformers:
    - polymer:
    entry_points:
    ...
    inline_stylesheets:
    web/asset/examples.css: false
    lib/asset/smoothness/jquery-ui-1.8.16.custom.css: false

    关于dart - 为什么Dart Polymer将主CSS文件内联/硫化到<head>标签中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29916082/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com