Skip to content
This repository was archived by the owner on Jan 21, 2022. It is now read-only.

Commit 4f27291

Browse files
committed
v2.1.0
1 parent 907d5e6 commit 4f27291

14 files changed

+2991
-157
lines changed

Diff for: .editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
charset = utf-8
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
9+
[package.json]
10+
indent_style = space
11+
indent_size = 2
12+
13+
[*.md]
14+
indent_style = space
15+
indent_size = 4
16+
trim_trailing_whitespace = false

Diff for: .eslintrc.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
module.exports = {
2-
'extends': 'trigen/base'
2+
'extends': 'trigen/base',
3+
'env': {
4+
'node': true
5+
}
36
};

Diff for: .gitignore

+10-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ lib-cov
1313

1414
# Coverage directory used by tools like istanbul
1515
coverage
16-
17-
# nyc test coverage
1816
.nyc_output
1917

2018
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
@@ -26,12 +24,20 @@ coverage
2624
# Compiled binary addons (http://nodejs.org/api/addons.html)
2725
build/Release
2826

29-
# Dependency directories
27+
# Dependency directory
3028
node_modules
31-
jspm_packages
3229

3330
# Optional npm cache directory
3431
.npm
3532

3633
# Optional REPL history
3734
.node_repl_history
35+
36+
# OS X stuff
37+
.DS_Store
38+
39+
# Some caches
40+
.eslintcache
41+
42+
# Compiled dist
43+
lib

Diff for: .npmignore

-2
This file was deleted.

Diff for: CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7+
8+
## [2.1.0] - 2017-11-23
9+
### Changed
10+
- `babel-cli` -> `Rollup`
11+
- `Promise/then` -> `async/await`
12+
- Upgrade to `[email protected]`

Diff for: README.md

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
[![NPM](https://nodei.co/npm/gulp-progressive-css.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/gulp-progressive-css/)
2-
31
# gulp-progressive-css
42

3+
[![NPM version][npm]][npm-url]
4+
[![Node version][node]][node-url]
5+
[![Dependency status][deps]][deps-url]
6+
7+
[npm]: https://img.shields.io/npm/v/gulp-progressive-css.svg
8+
[npm-url]: https://www.npmjs.com/package/gulp-progressive-css
9+
10+
[node]: https://img.shields.io/node/v/gulp-progressive-css.svg
11+
[node-url]: https://nodejs.org
12+
13+
[deps]: https://img.shields.io/david/TrigenSoftware/gulp-progressive-css.svg
14+
[deps-url]: https://david-dm.org/TrigenSoftware/gulp-progressive-css
15+
516
Transfrom `<link>` in HTML to progressive CSS loading.
617

7-
# Getting Started
18+
# Install
819

9-
Install with npm
1020
```bash
1121
npm i -D gulp-progressive-css
12-
```
13-
or
14-
```bash
22+
# or
1523
yarn add -D gulp-progressive-css
1624
```
1725

@@ -89,3 +97,6 @@ gulp.task('html', gulp.series('css', () =>
8997
.pipe(gulp.dest('dist'))
9098
));
9199
```
100+
101+
---
102+
[![NPM](https://nodei.co/npm/gulp-progressive-css.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/gulp-progressive-css/)

Diff for: example/dist/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ <h1>Footer</h1>
6868
</main>
6969
</footer>
7070
<script>
71-
!(function(w){'use strict';w.importCSS=j;var d=document,e=d.body||d.getElementsByTagName('head')[0],f=d.styleSheets,g=[];function h(a,b){for(var c=f.length;c--;)if(f[c].href===a)return void b();setTimeout(function(){h(a,b)})}function j(a,b,c){function k(){return n&&(m.media=b||'all'),n}function l(){m.addEventListener&&m.removeEventListener('load',l),n=!0;var o=!0;c?k():g=g.filter(function(p){return!(o=o&&p())})}var m=d.createElement('link'),n=!1;m.rel='stylesheet',m.href=a,m.media='only x',c||g.push(k),e.insertBefore(m,null),m.addEventListener&&m.addEventListener('load',l),h(m.href,l)}})(window);
71+
(function(){'use strict';function a(b,d){for(var e=c.length;e--;)if(c[e].href===b)return void d();setTimeout(function(){a(b,d)})}var b=window.document,c=b.styleSheets,d=b.body||b.getElementsByTagName('head')[0],e=[];window.importCSS=function(c,f,g){function h(){return k&&(j.media=f||'all'),k}function i(){j.addEventListener&&j.removeEventListener('load',i),k=!0;var a=!0;g?h():e=e.filter(function(b){return!(a=a&&b())})}var j=b.createElement('link'),k=!1;j.rel='stylesheet',j.href=c,j.media='only x',g||e.push(h),d.insertBefore(j,null),j.addEventListener&&j.addEventListener('load',i),a(j.href,i)}})();;
7272
importCSS('//google.com/font.css', 0, true);
7373
importCSS('content.css');
7474
importCSS('footer.css');

Diff for: example/dist/loader.php

-32
This file was deleted.

Diff for: package.json

+46-17
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
{
22
"name": "gulp-progressive-css",
3-
"version": "2.0.1",
3+
"version": "2.1.0",
44
"description": "Transfrom `<link>` in HTML to progressive CSS loading.",
5+
"author": "dangreen",
6+
"license": "MIT",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/TrigenSoftware/gulp-progressive-css.git"
10+
},
11+
"bugs": {
12+
"url": "https://github.com/TrigenSoftware/gulp-progressive-css/issues"
13+
},
514
"main": "lib/index.js",
15+
"engines": {
16+
"node": ">=6.0.0"
17+
},
618
"scripts": {
7-
"eslint": "eslint --cache 'src/*.js'",
19+
"lint": "eslint --cache 'src/*.js'",
820
"compile": "npm run eslint && babel ./src -d ./lib",
9-
"prepublish": "npm run eslint && npm run compile"
21+
"build": "rollup -c",
22+
"watch": "rollup -c -w",
23+
"prepublishOnly": "npm run build"
1024
},
11-
"repository": "https://github.com/TrigenSoftware/gulp-progressive-css",
12-
"author": "dangreen",
13-
"license": "MIT",
1425
"keywords": [
1526
"gulp",
1627
"gulpplugin",
@@ -20,27 +31,45 @@
2031
],
2132
"dependencies": {
2233
"detect-indent": "^5.0.0",
23-
"html-minifier": "^3.3.1",
24-
"import-css": "^2.0.0",
34+
"html-minifier": "^3.5.6",
35+
"import-css": "^3.0.0",
2536
"pn": "^1.0.0",
2637
"through2": "^2.0.3",
27-
"vinyl": "^2.0.1"
38+
"vinyl": "^2.1.0"
2839
},
2940
"devDependencies": {
30-
"babel-cli": "^6.23.0",
41+
"babel-core": "^6.26.0",
3142
"babel-plugin-add-module-exports": "^0.2.1",
32-
"babel-preset-es2015": "^6.22.0",
33-
"babel-preset-stage-0": "^6.22.0",
34-
"eslint": "^3.15.0",
35-
"eslint-config-trigen": "^1.1.0"
43+
"babel-plugin-transform-runtime": "^6.23.0",
44+
"babel-preset-env": "^1.6.1",
45+
"babel-preset-stage-0": "^6.24.1",
46+
"escope": "^3.6.0",
47+
"eslint": "^4.11.0",
48+
"eslint-config-trigen": "^2.3.0",
49+
"rollup": "^0.51.8",
50+
"rollup-plugin-babel": "^3.0.2",
51+
"rollup-plugin-commonjs": "^8.2.6",
52+
"rollup-plugin-eslint": "^4.0.0",
53+
"rollup-plugin-node-resolve": "^3.0.0"
3654
},
3755
"babel": {
3856
"presets": [
39-
"es2015",
57+
[
58+
"env",
59+
{
60+
"targets": {
61+
"node": "6"
62+
}
63+
}
64+
],
4065
"stage-0"
4166
],
4267
"plugins": [
43-
"add-module-exports"
68+
"add-module-exports",
69+
"transform-runtime"
4470
]
45-
}
71+
},
72+
"files": [
73+
"lib"
74+
]
4675
}

Diff for: rollup.config.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import commonjs from 'rollup-plugin-commonjs';
2+
import resolve from 'rollup-plugin-node-resolve';
3+
import babel from 'rollup-plugin-babel';
4+
import eslint from 'rollup-plugin-eslint';
5+
import pkg from './package.json';
6+
7+
const plugins = [
8+
eslint({
9+
exclude: ['**/*.json', 'node_modules/**'],
10+
throwOnError: process.env.ROLLUP_WATCH != 'true'
11+
}),
12+
babel(Object.assign({
13+
runtimeHelpers: true,
14+
babelrc: false,
15+
exclude: 'node_modules/**'
16+
}, pkg.babel, {
17+
presets: pkg.babel.presets.map((preset) => {
18+
19+
if (Array.isArray(preset) && preset[0] == 'env') {
20+
preset[1].modules = false;
21+
}
22+
23+
return preset
24+
})
25+
})),
26+
resolve({
27+
preferBuiltins: true
28+
}),
29+
commonjs()
30+
];
31+
32+
const dependencies = [].concat(
33+
['path', 'url'],
34+
Object.keys(pkg.dependencies)
35+
);
36+
37+
function external(id) {
38+
return dependencies.some(_ =>
39+
_ == id || id.indexOf(`${_}/`) == 0
40+
);
41+
}
42+
43+
export default {
44+
input: 'src/index.js',
45+
watch: {
46+
include: 'src/**/*.js'
47+
},
48+
plugins,
49+
external,
50+
output: {
51+
file: pkg.main,
52+
format: 'cjs',
53+
sourcemap: true
54+
}
55+
};

Diff for: src/index.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import Transformer from './transformer';
21
import through from 'through2';
2+
import Transformer from './transformer';
33

44
export default function plugin(inputOptions) {
55

@@ -12,17 +12,28 @@ export default function plugin(inputOptions) {
1212

1313
const transformer = new Transformer(options);
1414

15-
function each(file, enc, next) {
15+
async function each(file, enc, next) {
1616

1717
if (file.isNull() || file.isStream()) {
1818
next(null, file);
1919
return;
2020
}
2121

22-
transformer.transformHtmlFile(file).then((files) => {
23-
files.forEach(file => this.push(file));
22+
try {
23+
24+
const files = await transformer.transformHtmlFile(file);
25+
26+
files.forEach((file) => {
27+
this.push(file);
28+
});
29+
2430
next(null);
25-
}).catch(next);
31+
return;
32+
33+
} catch (err) {
34+
next(err);
35+
return;
36+
}
2637
}
2738

2839
return through.obj(each);

0 commit comments

Comments
 (0)