Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

edp-build-inline

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edp-build-inline

Auto inline css/html/img/svg etc. processor for edp build

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

edp-build-inline

EDP Build plugin for inline resource

edp-build-inlnie 是 edp-build 的一个插件,用于内联静态资源,支持图片、脚本、样式等。

如何使用

.icon {
    /* 使用查询参数方式指定要内联的图片 */
    background: url(img/loading.gif?_inline)
}
    var InlineProcessor = require('edp-build-inline');
    
    // 复杂自定义任务
    var escapeTask = function (file) {
        return file.data.replace(/\{|\}/g, function (match) {
            return {'{': '{ldelim}', '}': '{rdelim}'}[match];
        });
    };
    var inlineProcessor = new InlineProcessor({
        files: ['templates/index.tpl'],
        customTask: {
            js: escapeTask,
            css: escapeTask
        },
        inlineOption: {
            img: true,
            inlinePathGetter: function (path) {
                var newPath = path.replace(/\{\$host\}\//, '');
                return {path: newPath, dir: '.'};
            }
        }
    });
    
    // 简单:只对样式图片内联
    var inlineProcessor = new InlineProcessor({
        files: ['src/main.css'],
        inlineOption: {
            img: {
                limit: 1024 * 5 // 小于 5kb 图片才内联
            }
        }
    });
        
    return {
        'default': [
            lessProcessor, moduleProcessor, inlineProcessor, pathMapperProcessor
        ],

        'release': [
            lessProcessor, cssProcessor, moduleProcessor,
            jsProcessor, inlineProcessor, pathMapperProcessor, addCopyright
        ]
    };

更多内联选项 inlineOption 参考 inline-resource

Keywords

FAQs

Package last updated on 19 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc