简体   繁体   English

用于将CSS文件打包为JavaScript字符串的工具

[英]Tool for packing css files as JavaScript string

I'm looking for an external tool for creating valid JavaScript strings from a css file. 我正在寻找用于从css文件创建有效的JavaScript字符串的外部工具。

The content of the css file should be well escaped and compressed (if possible) into a JavaScript string. CSS文件的内容应充分逃脱,压缩(如果可能)成JavaScript字符串。

The reason for that is, that I'd like to deliver my library only in one file, the JavaScript file. 这样做的原因是,我只想在一个文件(JavaScript文件)中提供库。 Consider, this cannot (?) be done with the common webassets/packaging/compressing tools. 想想,这不能(?),可与普通webassets /包装/压缩工具来完成。

Any ideas? 有任何想法吗? Best regards. 最好的祝福。

I'd like to answer my own question. 我想回答我自己的问题。

The (NodeJS-) projects https://github.com/GoalSmashers/clean-css and https://github.com/mathiasbynens/jsesc fits the requirements. (NodeJS-)项目https://github.com/GoalSmashers/clean-csshttps://github.com/mathiasbynens/jsesc符合要求。

Usage: 用法:

cleancss input.css -o input.min.css
jsesc < input.min.css > output.txt

The output.txt file contains the well escaped JavaScript string. output.txt文件包含转义良好的JavaScript字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM