Skip to content

Commit

Permalink
feat(compiler-sass): Sourcemap generating
Browse files Browse the repository at this point in the history
support generate sourcemap
  • Loading branch information
Genuifx committed Sep 12, 2019
1 parent 5074b5e commit 8ac1420
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions packages/wxa-compiler-sass/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,25 @@ class SassCompiler {
if(this.configs == null) this.configs = configs || {};
}

async parse(mdl, cmdConfigs, compilation) {
async parse(mdl, cmdOptions, compilation) {
debug('sass module parse started %O', mdl);
// custom outputPath
if(mdl.meta) {
let source = path.parse(mdl.meta.source);
mdl.meta.source = source.dir + path.sep + source.name + '.css';

let output = path.parse(mdl.meta.outputPath);
mdl.meta.outputPath = output.dir + path.sep + output.name + '.css'
}

let configs = this.configs;

if (cmdOptions && cmdOptions.sourceMap) {
// inline css sourcemap.
configs.sourceMap = cmdOptions.sourceMap;
configs.sourceMapEmbed = true;
}

let ret = await this.render(mdl.content || null, mdl.meta.source, configs);

mdl.code = ret.css.toString();
Expand All @@ -34,15 +48,6 @@ class SassCompiler {
});
}

// custom outputPath
if(mdl.meta) {
let source = path.parse(mdl.meta.source);
mdl.meta.source = source.dir + path.sep + source.name + '.css';

let output = path.parse(mdl.meta.outputPath);
mdl.meta.outputPath = output.dir + path.sep + output.name + '.css'
}

return {ret, code: mdl.code};
}

Expand Down

0 comments on commit 8ac1420

Please sign in to comment.