Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inline processor 需求 #70

Open
junmer opened this issue Dec 25, 2014 · 8 comments
Open

inline processor 需求 #70

junmer opened this issue Dec 25, 2014 · 8 comments

Comments

@junmer
Copy link
Contributor

junmer commented Dec 25, 2014

在某些场景下(如移动端),需要 把一些 js or css 放到 <head>

所以期望有个 processor 可以做以下 工作

edp-build-config.js

var inlinePorcessor = new InlinePorcessor({
    extnames: 'html,tpl'
});

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script>
        {edp-inline:'src/common/meta.js'}
    </script>
    <style>
        {edp-inline:'src/common/head.css'}
    </style>
</head>
<body>
    hello
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script>
        /* meta.js content */
    </script>
    <style>
        /* head.css content */
    </style>
</head>
<body>
    hello
</body>
</html>
@leeight
Copy link
Member

leeight commented Dec 25, 2014

使用 StringReplace 这个大杀器?

@junmer
Copy link
Contributor Author

junmer commented Dec 25, 2014

StringReplace 实现build当然没啥问题, 开发阶段ws还需要 一个 inline-handler,来干这个事
所以希望这个 配置写在html里,这样handler也从这里读文件

@junmer
Copy link
Contributor Author

junmer commented Dec 25, 2014

@leeight @firede @treelite 请看下,这个接口设计是否合理,合理的话,我就开撸啦?

@treelite
Copy link
Contributor

👌 倾向使用注释的方式,另外可以考虑提供配置支持嵌入代码的压缩与否,方便调试

@junmer
Copy link
Contributor Author

junmer commented Dec 25, 2014

etpl 节奏么

<!-- include: xxx.xxx -->

@firede
Copy link
Member

firede commented Dec 25, 2014

https://github.com/ecomfe/edp/wiki/Package-Management#%E5%AF%BC%E5%85%A5%E5%B9%B6%E4%BD%BF%E7%94%A8%E5%8C%85

这个链接再往下翻一点,记得有使用注释风格的先例。

@zengjialuo
Copy link
Member

是不是可以借鉴 fis 的做法,在 html 里加 __inline 标志,这样就不用在 webServer 里再处理了
(逃

@junmer
Copy link
Contributor Author

junmer commented Jan 4, 2015

今天 实现了一个

<!-- edp-inline: xxx.xxx -->

build 没问题,但是 实现 webserver 发现个坑,因为 搞不定.less这类预编译的文件

删掉 重来 ( ╯-_-)╯┴—┴

这次,参考 @zengjialuo 的建议,这样搞的

<link data-inline rel="stylesheet" href="./src/css/path-mapper.css">
<script data-inline src="./src/foo.js"></script>

并且提供 自定义配置 data-inline 属性

This was referenced Jan 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants