Skip to content

Commit 012f9f5

Browse files
committed
fix support for scss file (#22)
1 parent 351a321 commit 012f9f5

File tree

3 files changed

+105
-8
lines changed

3 files changed

+105
-8
lines changed

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ const stringify = require("./stringify");
44
const parse = require("./parse");
55
const defaultConfig = {
66
rules: [
7-
{
8-
// WXSS(WeiXin Style Sheets) See: https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxss.html
9-
// acss(AntFinancial Style Sheet) See: https://docs.alipay.com/mini/framework/acss
10-
// `*.pcss`, `*.postcss`
11-
test: /\.(?:wx|\w*c)ss$/i,
12-
lang: "css",
13-
},
147
{
158
test: /\.less$/i,
169
lang: "less",
@@ -31,6 +24,13 @@ const defaultConfig = {
3124
test: /\.styl(?:us)?$/i,
3225
lang: "stylus",
3326
},
27+
{
28+
// WXSS(WeiXin Style Sheets) See: https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxss.html
29+
// acss(AntFinancial Style Sheet) See: https://docs.alipay.com/mini/framework/acss
30+
// `*.pcss`, `*.postcss`
31+
test: /\.(?:wx|\w*c)ss$/i,
32+
lang: "css",
33+
},
3434
{
3535
test: /\.(?:[sx]?html?|[sx]ht|vue|ux|markdown|md|php)$/i,
3636
extract: "html",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcss-syntax",
3-
"version": "0.26.0",
3+
"version": "0.26.1",
44
"description": "Automatically switch PostCSS syntax by file extensions",
55
"repository": {
66
"type": "git",

test/rules.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
"use strict";
2+
const rules = require("../").config.rules;
3+
const expect = require("chai").expect;
4+
function getRule (file) {
5+
let rst = rules.filter(rule => rule.test.test(file));
6+
if (rst.length === 1) {
7+
rst = rst[0];
8+
}
9+
return rst;
10+
}
11+
12+
describe("default config rules", () => {
13+
it("foo.css", () => {
14+
expect(getRule("foo.css")).to.haveOwnProperty("lang", "css");
15+
});
16+
it("foo.pcss", () => {
17+
expect(getRule("foo.pcss")).to.haveOwnProperty("lang", "css");
18+
});
19+
it("foo.postcss", () => {
20+
expect(getRule("foo.postcss")).to.haveOwnProperty("lang", "css");
21+
});
22+
it("foo.wxss", () => {
23+
expect(getRule("foo.wxss")).to.haveOwnProperty("lang", "css");
24+
});
25+
it("foo.acss", () => {
26+
expect(getRule("foo.acss")).to.haveOwnProperty("lang", "css");
27+
});
28+
it("foo.less", () => {
29+
expect(getRule("foo.less")).to.haveOwnProperty("lang", "less");
30+
});
31+
it("foo.sass", () => {
32+
expect(getRule("foo.sass")).to.haveOwnProperty("lang", "sass");
33+
});
34+
it("foo.sass", () => {
35+
expect(getRule("foo.sass")).to.haveOwnProperty("lang", "sass");
36+
});
37+
it("foo.sss", () => {
38+
expect(getRule("foo.sss")).to.haveOwnProperty("lang", "sugarss");
39+
});
40+
it("foo.sugarss", () => {
41+
expect(getRule("foo.sugarss")).to.haveOwnProperty("lang", "sugarss");
42+
});
43+
it("foo.styl", () => {
44+
expect(getRule("foo.styl")).to.haveOwnProperty("lang", "stylus");
45+
});
46+
it("foo.stylus", () => {
47+
expect(getRule("foo.stylus")).to.haveOwnProperty("lang", "stylus");
48+
});
49+
it("foo.html", () => {
50+
expect(getRule("foo.html")).to.haveOwnProperty("extract", "html");
51+
});
52+
it("foo.htm", () => {
53+
expect(getRule("foo.htm")).to.haveOwnProperty("extract", "html");
54+
});
55+
it("foo.xht", () => {
56+
expect(getRule("foo.xht")).to.haveOwnProperty("extract", "html");
57+
});
58+
it("foo.shtml", () => {
59+
expect(getRule("foo.shtml")).to.haveOwnProperty("extract", "html");
60+
});
61+
it("foo.php", () => {
62+
expect(getRule("foo.php")).to.haveOwnProperty("extract", "html");
63+
});
64+
it("foo.md", () => {
65+
const rst = getRule("foo.md");
66+
expect(rst).to.lengthOf(2);
67+
expect(rst[0]).to.haveOwnProperty("extract", "html");
68+
expect(rst[1]).to.haveOwnProperty("extract", "markdown");
69+
});
70+
it("foo.markdown", () => {
71+
const rst = getRule("foo.markdown");
72+
expect(rst).to.lengthOf(2);
73+
expect(rst[0]).to.haveOwnProperty("extract", "html");
74+
expect(rst[1]).to.haveOwnProperty("extract", "markdown");
75+
});
76+
it("foo.js", () => {
77+
expect(getRule("foo.js")).to.haveOwnProperty("extract", "jsx");
78+
});
79+
it("foo.mjs", () => {
80+
expect(getRule("foo.mjs")).to.haveOwnProperty("extract", "jsx");
81+
});
82+
it("foo.jsx", () => {
83+
expect(getRule("foo.jsx")).to.haveOwnProperty("extract", "jsx");
84+
});
85+
it("foo.ts", () => {
86+
expect(getRule("foo.ts")).to.haveOwnProperty("extract", "jsx");
87+
});
88+
it("foo.tsx", () => {
89+
expect(getRule("foo.tsx")).to.haveOwnProperty("extract", "jsx");
90+
});
91+
it("foo.es6", () => {
92+
expect(getRule("foo.es6")).to.haveOwnProperty("extract", "jsx");
93+
});
94+
it("foo.es2017", () => {
95+
expect(getRule("foo.es2017")).to.haveOwnProperty("extract", "jsx");
96+
});
97+
});

0 commit comments

Comments
 (0)