diff --git a/packages/mars-build/package.json b/packages/mars-build/package.json index b12a64ba..ed970ed1 100644 --- a/packages/mars-build/package.json +++ b/packages/mars-build/package.json @@ -26,6 +26,7 @@ "node-sass": "^4.11.0", "postcss": "^7.0.14", "postcss-px2units": "^0.2.0", + "slash": "^3.0.0", "stylus": "^0.54.5", "through2": "^3.0.0", "vinyl": "^2.2.0", diff --git a/packages/mars-build/src/gulp-mars-base.js b/packages/mars-build/src/gulp-mars-base.js index a791ae87..6c28ae9b 100644 --- a/packages/mars-build/src/gulp-mars-base.js +++ b/packages/mars-build/src/gulp-mars-base.js @@ -12,6 +12,7 @@ const PluginError = gutil.PluginError; const PLUGIN_NAME = 'gulp-mars'; const path = require('path'); const mkdirp = require('mkdirp'); +const slash = require('slash'); const {parse: sfcParser} = require('./compiler/sfc/parser'); const {compile: sfcCompiler} = require('./compiler/sfc/compiler'); @@ -28,7 +29,7 @@ function compile(file, opt, compilers) { } } = opt; const rPath = path.relative(file.base, file.path); - const fPath = path.resolve(file.cwd, opt.dest, rPath).replace(/\.vue$/, ''); + const fPath = slash(path.resolve(file.cwd, opt.dest, rPath).replace(/\.vue$/, '')); const baseName = path.basename(fPath); let coreRelativePath = path.join( @@ -39,7 +40,7 @@ function compile(file, opt, compilers) { opt.coreDir || 'common' ); coreRelativePath = coreRelativePath[0] === '.' ? coreRelativePath : './' + coreRelativePath; - coreRelativePath = coreRelativePath + `/${target}/index`; + coreRelativePath = slash(coreRelativePath + `/${target}/index`); try { const dirPath = fPath.replace(/[^/]+$/, '');