【发布时间】:2019-03-09 13:14:56
【问题描述】:
我将聚合物 1 上的 WebApp 打包到 chrome 扩展,其中不允许内联 js 脚本。
是否有任何现成的自动解决方案(例如 webpack 插件)可以将嵌入 HTML 文件中的所有 js 脚本移动到单独的文件中并进一步连接。
例如:
example-view.html:
<dom-module id="editable-name-tag">
<template>
<p>This is <strong>{{owner}}</strong>'s editable-name-tag.</p>
<input is="iron-input" bind-value="{{owner}}"
placeholder="Your name here...">
</template>
<script>
Polymer({
is: "editable-name-tag",
properties: {
owner: {
type: String,
value: "Daniel"
}
}
});
</script>
</dom-module>
转换为:
example-view.html:
<dom-module id="editable-name-tag">
<template>
<p>This is <strong>{{owner}}</strong>'s editable-name-tag.</p>
<input is="iron-input" bind-value="{{owner}}"
placeholder="Your name here...">
</template>
<script src="script.js"></script>
</dom-module>
和script.js:
Polymer({
is: "editable-name-tag",
properties: {
owner: {
type: String,
value: "Daniel"
}
}
});
【问题讨论】:
-
这就是它的作用:npmjs.com/package/crisper
-
@Michael Updike,谢谢。如果您发布它作为答案,我会选择这个
标签: javascript html webpack polymer-1.0