gulp-component-inline
Advanced tools
Comparing version 1.0.2 to 1.0.3
18
index.js
@@ -7,2 +7,3 @@ 'use strict'; | ||
var template = require('ali-arttemplate'); | ||
var sass = require('sass'); | ||
var cssmin = require('cssmin'); | ||
@@ -13,3 +14,3 @@ var gutil = require('gulp-util'); | ||
var PLUGIN_NAME = 'gulp-component-inline'; | ||
var INLINE_REGEX = /__inline\([^\)].*\)/m; | ||
var INLINE_REGEX = /__inline\([^\)].*\)/mg; | ||
var FILE_REGEX = /__inline\(["']([^"^']*)/; | ||
@@ -31,3 +32,3 @@ | ||
if (file.isBuffer()) { | ||
var contents = fs.readFileSync(file, 'utf-8'); | ||
var contents = fs.readFileSync(file.path, 'utf-8'); | ||
@@ -45,3 +46,3 @@ contents = contents.replace(INLINE_REGEX, function(matchString, index) { | ||
if(/\.css$/.test(compFile)) { | ||
if (/\.s?css$/.test(compFile)) { | ||
compileResult = compileCss(compFile); | ||
@@ -56,5 +57,12 @@ } else { | ||
function compileCss(compFile) { | ||
var result = fs.readFileSync(compFile, 'utf-8'); | ||
var result; | ||
result = cssmin(result); | ||
if (/\.scss$/.test(compFile)) { | ||
result = sass.renderSync({file:compFile}); | ||
result = cssmin(String(result.css)); | ||
} else { | ||
result = fs.readFileSync(compFile, 'utf-8'); | ||
result = cssmin(result); | ||
} | ||
result = result.replace(/\'/g, '"'); | ||
@@ -61,0 +69,0 @@ |
{ | ||
"name": "gulp-component-inline", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Support for referencing artTemplate file (or css files) directly in JS by '__inline', then compile them into JS", | ||
@@ -39,2 +39,3 @@ "license": "MIT", | ||
"gulp-util": "^3.0.8", | ||
"sass": "^1.0.0-beta.2", | ||
"through2": "^2.0.3" | ||
@@ -44,5 +45,4 @@ }, | ||
"mocha": "^3.5.0", | ||
"should": "^13.0.1", | ||
"vinyl": "^2.1.0" | ||
"should": "^13.0.1" | ||
} | ||
} |
# gulp-component-inline | ||
[![Build Status](travis-img)](travis-url) | ||
[![Coverage Status](coveralls-img)](coveralls-url) | ||
[![Build Status][travis-img]][travis-url] | ||
[![Coverage Status][coveralls-img]][coveralls-url] | ||
[![License][license-img]][license-url] | ||
@@ -5,0 +5,0 @@ |
5248
2
62
5
+ Addedsass@^1.0.0-beta.2
+ Added@parcel/watcher@2.5.1(transitive)
+ Added@parcel/watcher-android-arm64@2.5.1(transitive)
+ Added@parcel/watcher-darwin-arm64@2.5.1(transitive)
+ Added@parcel/watcher-darwin-x64@2.5.1(transitive)
+ Added@parcel/watcher-freebsd-x64@2.5.1(transitive)
+ Added@parcel/watcher-linux-arm-glibc@2.5.1(transitive)
+ Added@parcel/watcher-linux-arm-musl@2.5.1(transitive)
+ Added@parcel/watcher-linux-arm64-glibc@2.5.1(transitive)
+ Added@parcel/watcher-linux-arm64-musl@2.5.1(transitive)
+ Added@parcel/watcher-linux-x64-glibc@2.5.1(transitive)
+ Added@parcel/watcher-linux-x64-musl@2.5.1(transitive)
+ Added@parcel/watcher-win32-arm64@2.5.1(transitive)
+ Added@parcel/watcher-win32-ia32@2.5.1(transitive)
+ Added@parcel/watcher-win32-x64@2.5.1(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedchokidar@4.0.3(transitive)
+ Addeddetect-libc@1.0.3(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedimmutable@5.0.3(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addednode-addon-api@7.1.1(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedreaddirp@4.1.2(transitive)
+ Addedsass@1.85.0(transitive)
+ Addedsource-map-js@1.2.1(transitive)
+ Addedto-regex-range@5.0.1(transitive)