From f07860d3098133f1485e2232848298fa33f343b8 Mon Sep 17 00:00:00 2001 From: Wei Zhu Date: Mon, 3 Feb 2020 09:00:25 +0800 Subject: [PATCH] fix: windows path (#190) --- src/index.js | 7 ++++--- src/utils/humanlize-path.js | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index 767d3ea7..f51465a4 100644 --- a/src/index.js +++ b/src/index.js @@ -2,6 +2,7 @@ import path from 'path' import { createFilter } from 'rollup-pluginutils' import Concat from 'concat-with-sourcemaps' import Loaders from './loaders' +import normalizePath from './utils/normalize-path' /** * The options that could be `boolean` or `object` @@ -114,11 +115,11 @@ export default (options = {}) => { const getExtracted = () => { const fileName = typeof postcssLoaderOptions.extract === 'string' ? - path.relative(dir, postcssLoaderOptions.extract) : + normalizePath(path.relative(dir, postcssLoaderOptions.extract)) : `${path.basename(file, path.extname(file))}.css` const concat = new Concat(true, fileName, '\n') const entries = Array.from(extracted.values()) - const { modules } = bundle[path.relative(dir, file)] + const { modules } = bundle[normalizePath(path.relative(dir, file))] if (modules) { const fileList = Object.keys(modules) @@ -127,7 +128,7 @@ export default (options = {}) => { ) } for (const res of entries) { - const relative = path.relative(dir, res.id) + const relative = normalizePath(path.relative(dir, res.id)) const map = res.map || null if (map) { map.file = fileName diff --git a/src/utils/humanlize-path.js b/src/utils/humanlize-path.js index b1d92739..d2ac83a3 100644 --- a/src/utils/humanlize-path.js +++ b/src/utils/humanlize-path.js @@ -1,6 +1,7 @@ import path from 'path' +import normalizePath from './normalize-path' -const humanlizePath = filepath => path.relative(process.cwd(), -filepath) +const humanlizePath = filepath => normalizePath(path.relative(process.cwd(), +filepath)) export default humanlizePath