Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ See [resolve option](https://github.com/postcss/postcss-import#resolve) for more
([#120](https://github.com/postcss/postcss-import/pull/120))
- Changed: custom resolve should include glob resolver
([#121](https://github.com/postcss/postcss-import/pull/121))
- Added: custom syntax in imported files support
([#130](https://github.com/postcss/postcss-import/pull/130))
- Changed: glob resolver do not add `moduleDirectories` and parse all uri as glob patterns
([#131](https://github.com/postcss/postcss-import/pull/131))

# 7.1.3 - 2015-11-05

Expand Down
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ function AtImport(options) {
})

return function(styles, result) {
options.parser = postcss.parse
if (result.opts.syntax) {
options.parser = result.opts.syntax.parse
}
if (result.opts.parser) {
options.parser = result.opts.parser
}
if (options.parser.parse) {
options.parser = options.parser.parse
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document this (at least in the CHANGELOG?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's postcss code part. Everything is in postcss doc. I'll add changelog

var state = {
importedFiles: {},
hashFiles: {},
Expand Down Expand Up @@ -252,7 +263,8 @@ function readImportedContent(
return
}

var newStyles = postcss.parse(fileContent, options)
var newStyles = options.parser(fileContent, options)

if (options.skipDuplicates) {
var hasImport = newStyles.some(function(child) {
return child.type === "atrule" && child.name === "import"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"devDependencies": {
"ava": "^0.8.0",
"css-whitespace": "^1.1.1",
"eslint": "^1.1.0"
"eslint": "^1.1.0",
"postcss-scss": "^0.1.3"
},
"scripts": {
"lint": "eslint .",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/imports/inline-comment.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// inline comment
1 change: 1 addition & 0 deletions test/fixtures/scss-parser.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "inline-comment.scss";
1 change: 1 addition & 0 deletions test/fixtures/scss-parser.expected.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* inline comment*/
1 change: 1 addition & 0 deletions test/fixtures/scss-syntax.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "inline-comment.scss";
1 change: 1 addition & 0 deletions test/fixtures/scss-syntax.expected.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// inline comment
13 changes: 13 additions & 0 deletions test/plugins.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test from "ava"
import postcss from "postcss"
import scss from "postcss-scss"
import atImport from ".."
import compareFixtures from "./lib/compare-fixtures"

Expand Down Expand Up @@ -42,3 +43,15 @@ test("should remain silent when value is an empty array", () => {
}))
.process("")
})

test("should process custom syntax", t => {
return compareFixtures(t, "scss-syntax", null, {
syntax: scss,
})
})

test("should process custom syntax by parser", t => {
return compareFixtures(t, "scss-parser", null, {
parser: scss,
})
})