Skip to content

Commit 5db3542

Browse files
committed
Update postcss-simple-import to use on option
1 parent 16cb0af commit 5db3542

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

index.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var Pipeline = require('postcss-processor-splicer')
22
var CacheHandler = require('deps-cache')
3-
var path = require('path')
43

54
module.exports = function (b, opts) {
65
opts = opts || {}
@@ -31,20 +30,18 @@ module.exports = function (b, opts) {
3130

3231
var cacheHandler = new CacheHandler(cache)
3332

34-
var importer = atImportOpts.importer
35-
atImportOpts.importer = function (id, from, state) {
36-
return state.resolve(id, { basedir: path.dirname(from) })
37-
.then(function (dep) {
38-
cacheHandler.add(from, dep)
39-
// watchify reports file rather than `dep`,
40-
// so emit dep and make watchify report it
41-
b.emit('file', dep)
42-
// watch dep
43-
state.postcssOpts.entry.emit('file', dep)
44-
if (importer) {
45-
return importer(id, from, state)
46-
}
47-
})
33+
var on = atImportOpts.on = atImportOpts.on || {}
34+
var onImport = on.import
35+
on.import = function (dep, from, state) {
36+
cacheHandler.add(from, dep)
37+
// watchify reports file rather than `dep`,
38+
// so emit dep and make watchify report it
39+
b.emit('file', dep)
40+
// watch dep
41+
state.postcssOpts.entry.emit('file', dep)
42+
if (onImport) {
43+
onImport(dep, from, state)
44+
}
4845
}
4946

5047
// watchify emit `update` whenever file changes detected

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"postcss-mixins": "^2.1.1",
3232
"postcss-nested": "^1.0.0",
3333
"postcss-processor-splicer": "^2.0.0",
34-
"postcss-simple-import": "^2.0.1"
34+
"postcss-simple-import": "^2.1.0"
3535
},
3636
"devDependencies": {
3737
"callback-sequence": "^1.2.1",

0 commit comments

Comments
 (0)