Skip to content

Commit 493b963

Browse files
author
Tom Maton
committed
Updated READ.me, version number and now have the ability to ignore files to convert
1 parent c340dec commit 493b963

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ gulp.task("polymerize", () => {
4343
// string to be used for the end of the file name & module ids.
4444
suffix: '-styles',
4545
// boolean, determines how the styles are generated as differentate between Polymer and Polymer PWA
46-
pwa: true // default is false
46+
pwa: true // default is false,
47+
// array, an array of css files which you dont want to convert
48+
ignore: ['navigation.css'] // default is false
4749
}
4850
```
4951

index.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,31 @@ const generatePWAStyle = (styles, moduleId) => (`import { html } from '@polymer/
3939

4040
module.exports = opts => through.obj((file, enc, cb) => {
4141
const fileObj = file;
42-
43-
if (file.isStream()) {
44-
return cb(new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
45-
}
46-
if (file.isNull()) {
47-
return cb(null, file);
48-
}
49-
42+
const fileName = path.basename(file.path);
5043
const moduleId = generateModuleName(opts, file);
5144
const dirname = path.dirname(file.path);
5245
const isPWA = !!opts.pwa;
46+
const ignoreFiles = opts.ignore;
5347

54-
const res = (isPWA)
55-
? generatePWAStyle(file.contents, moduleId)
56-
: generatePolymerStyle(file.contents, moduleId);
48+
let res;
5749

58-
fileObj.contents = Buffer.from(res);
59-
fileObj.path = `${path.join(dirname, moduleId)}.js`;
50+
if (!ignoreFiles.includes(fileName)) {
51+
if (file.isStream()) {
52+
return cb(new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
53+
}
54+
if (file.isNull()) {
55+
return cb(null, file);
56+
}
57+
58+
res = (isPWA)
59+
? generatePWAStyle(file.contents, moduleId)
60+
: generatePolymerStyle(file.contents, moduleId);
61+
62+
fileObj.contents = Buffer.from(res);
63+
fileObj.path = `${path.join(dirname, moduleId)}.js`;
64+
65+
return cb(null, file);
66+
}
6067

61-
return cb(null, file);
68+
return null;
6269
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gulp-css-to-polymer",
3-
"version": "1.0.4",
3+
"version": "1.2.0",
44
"description": "Converting CSS to a ES6 Module for Polymer V3.x.x",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)