diff --git a/lib/task.js b/lib/task.js index 557e233..ce32175 100644 --- a/lib/task.js +++ b/lib/task.js @@ -30,11 +30,27 @@ exports.build = function (opts) { components = config.components.concat(['base']) cssFiles = '{' + components.join(',') + '}' } + var varsPath = path.resolve(config.themePath, './src/common/var.scss') - fs.writeFileSync(varsPath, fs.readFileSync(path.resolve(process.cwd(), opts.config || config.config)), 'utf-8') + var customPath = path.resolve(process.cwd(), opts.config || config.config) + var varsContent = fs.readFileSync(customPath, 'utf8') + fs.readFileSync(varsPath, 'utf8') stream = gulp.src([opts.config || config.config, path.resolve(config.themePath, './src/' + cssFiles + '.scss')]) - .pipe(sass.sync()) + .pipe(sass.sync({ + importer: function (url, prev) { + var dir = path.dirname(prev) + var file = path.resolve(dir, url) + if (!file.endsWith('.scss')) { + file += '.scss' + } + if (file === varsPath) { + return { + contents: varsContent + } + } + return null + } + })) .pipe(autoprefixer({ browsers: config.browsers, cascade: false