Skip to content

Commit

Permalink
修正CSS @import 多种语法的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
aui committed Dec 29, 2014
1 parent c3514f7 commit 664fa34
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "font-spider",
"description": "Font optimizer",
"version": "0.0.2",
"version": "0.0.3",
"homepage": "https://github.com/aui/font-spider",
"author": {
"name": "aui",
Expand Down
7 changes: 6 additions & 1 deletion src/optimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ Optimizer.prototype.minify = function (dest, chars) {

// result.output

fs.renameSync(temp, dest);
if (fs.existsSync(temp)) {
fs.renameSync(temp, dest);
} else {
console.error('error', result.output);
}

}

fs.unlinkSync(charsfile);
Expand Down
9 changes: 8 additions & 1 deletion src/spider.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,14 @@ Spider.prototype = {
case 'import':

RE_URL.lastIndex = 0;
var url = RE_URL.exec(rule['import'])[1];
var url = rule['import'];

// @import url("./g.css?t=2009");
// @import "./g.css?t=2009";
if (/url/i.test(url)) {
url = RE_URL.exec(url)[1];
}

url = url.replace(RE_QUERY, '');

if (!RE_SERVER.test(url)) {
Expand Down
Empty file added test/css/g2.css
Empty file.
1 change: 1 addition & 0 deletions test/css/ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/** Reset */
@import url("./g.css?t=2009");
@import "./g2.css";
@font-face {
font-family: 'art';
/*IE*/
Expand Down

0 comments on commit 664fa34

Please sign in to comment.