npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-parser-inline

v1.6.3

Published

![Language](https://img.shields.io/badge/-TypeScript-blue.svg) [![Build Status](https://travis-ci.org/searchfe/gulp-parser-inline.svg?branch=master)](https://travis-ci.org/searchfe/gulp-parser-inline) [![npm package](https://img.shields.io/npm/v/gulp-pars

Downloads

16

Readme

gulp-parser-inline

Language Build Status npm package npm downloads semantic-release

gulp插件,用于处理inline语法

inline plugin for gulp.

Install

npm install
npm build

Usage

在构建目录安装 gulp-parser-inline

npm install --save-dev gulp-parser-inline

在构建目录下创建 gulpfile.js


const staticDomain = process.env.dev ? '' : '//m.baidu.com';
const parse = require('gulp-parser-inline').parseInline;
const sanInline = require('gulp-parser-inline').parseSan;
// parse tpl
gulp.task('build:tpl', function (stream) {
    return gulp.src(['src/**/*.tpl'])
        .pipe(parse({
            base: path.resolve('./src/'),
            type: 'tpl',
            staticDomain: staticDomain,
            compress: true
        }))
        .pipe(gulp.dest('dist'));
});

gulp.task('build:js', function (stream) {
    return gulp.src(['src/**/*.js'])
        .pipe(parse({
            base: path.resolve('./src/'),
            type: 'js',
            staticDomain: staticDomain,
            useHash: true,
            compress: true
        }))
        .pipe(gulp.dest('dist'));
});

gulp.task('build:css', function (stream) {
    return gulp.src(['src/**/*.css'])
        .pipe(parse({
            base: path.resolve('./src/'),
            type: 'css',
            useHash: true,
            compress: true
        }))
        .pipe(gulp.dest('dist'));
});
// parseSan
gulp.task('san', ()=>{
  return gulp.src(['./test/*.san.ts'])
  .pipe(sanInline({basePath: path.resolve('./test')}))
  .pipe(gulp.dest('./output'));
});

运行

在gulpfile.js目录下执行如下命令

$ gulp

用法

构建路径基于base目录,若该目录下找不到该文件则会以当前文件目录为当前路径计算

1.js

js文件中的inline用法主要是将对应文件内容内联到当前js文件中

例:

__inline('./a.js');
var dom = __inline('./a.etpl');

构建后:

var a = 'I am a.js';
var dom = '<div>I am a.etpl</div>'

2.css

css文件中的inline用法除了将对应文件内容内联到当前css文件中外,还支持将图片文件转为base64

例:

@import url('./a.css?__inline');
.bg {
    background:url(./a.png?__inline);
}

构建后:

/* a.css文件内容 start */
.a {
    width: 100%;
}
/* a.css文件内容 end */
.bg {
    background:url(data:png;base64,iVBORw0KGgoAAAANSUh...);
}

3.tpl

把对应的文件内容内联到当前html(tpl)文件中。

例:

<link rel="stylesheet" href="/static/css/style.css?__inline" /> 
<style>
	__inline('/static/css/style.css')
</style>
<script>
__inline('a.js');
</script>

构建后:

<style>
	body,html{margin:0;padding:0}...略
</style>
<script>
define("a",[],function(n,a,i){a.run=function(){alert("i am a")}});
</script>