gulp-inline-ng2-template icon indicating copy to clipboard operation
gulp-inline-ng2-template copied to clipboard

How to use scss file with your gulp task

Open ofirrifo opened this issue 8 years ago • 2 comments

Hi,

Thanks for great gulp package.

How can I use this gulp package with scss files

Thanks

ofirrifo avatar Feb 12 '17 16:02 ofirrifo

#78 Can you take a look on this? if this solve your issue.

aelbore avatar Apr 16 '17 08:04 aelbore

const sass = require('node-sass');
const inlineNg2Template = require('gulp-inline-ng2-template');

const styleProcessor = (stylePath, ext, styleFile, callback) => {
  if (ext[0] === '.scss') {
    let sassObj = sass.renderSync({ file: stylePath });
    if (sassObj && sassObj['css']){
      styleFile = sassObj.css.toString('utf8');
    }
  }
  return callback(null, styleFile);  
};

const OPTIONS = {
  base: 'src', 
  useRelativePaths: true,
  styleProcessor: styleProcessor
}; 

const ng2InlineTemplate = () => {
  return inlineNg2Template(OPTIONS);
};

exports.ng2InlineTemplate = ng2InlineTemplate;

aelbore avatar Apr 16 '17 08:04 aelbore