Skip to content

Commit 5168c12

Browse files
shirotechlmihaidaniel
authored andcommitted
fixes #135 check map.source before pre-pending dirname (#136)
1 parent 77cfea4 commit 5168c12

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,15 @@ export default (options = {}) => {
8888

8989
async onwrite(opts) {
9090
if (extracted.size === 0) return
91+
const dirnameMain = path.dirname(opts.file)
9192

9293
const getExtracted = filepath => {
9394
if (!filepath) {
9495
if (typeof postcssLoaderOptions.extract === 'string') {
9596
filepath = postcssLoaderOptions.extract
9697
} else {
9798
const basename = path.basename(opts.file, path.extname(opts.file))
98-
filepath = path.join(path.dirname(opts.file), basename + '.css')
99+
filepath = path.join(dirnameMain, basename + '.css')
99100
}
100101
}
101102
filepath = humanlizePath(filepath)
@@ -106,7 +107,7 @@ export default (options = {}) => {
106107
if (map) {
107108
map.file = filepath
108109
map.sources = map.sources.map(source =>
109-
humanlizePath(path.join(path.dirname(opts.file), source))
110+
source.substr(0, dirnameMain.length) === dirnameMain ? source : humanlizePath(path.join(dirnameMain, source))
110111
)
111112
}
112113
concat.add(relative, res.code, map)

0 commit comments

Comments
 (0)