|
1 | 1 | var Pipeline = require('postcss-processor-splicer')
|
2 | 2 | var CacheHandler = require('deps-cache')
|
3 |
| -var path = require('path') |
4 | 3 |
|
5 | 4 | module.exports = function (b, opts) {
|
6 | 5 | opts = opts || {}
|
@@ -31,20 +30,18 @@ module.exports = function (b, opts) {
|
31 | 30 |
|
32 | 31 | var cacheHandler = new CacheHandler(cache)
|
33 | 32 |
|
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 | + } |
48 | 45 | }
|
49 | 46 |
|
50 | 47 | // watchify emit `update` whenever file changes detected
|
|
0 commit comments