From f70a1eed8fd11a2ac6af2e9e462cc30b6109d82d Mon Sep 17 00:00:00 2001 From: stylesuxx Date: Wed, 18 Nov 2015 04:33:58 +0100 Subject: [PATCH] Parse base config and add postcss related stuff --- generators/app/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/generators/app/index.js b/generators/app/index.js index eefa018..350e66a 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -134,6 +134,21 @@ module.exports = generator.Base.extend({ }, install: function() { + // Update base cfg if postcss is enabled + if(this.postcss) { + var baseConfigPath = path.join(this.destinationRoot(), 'cfg/base.js'); + var data = fs.readFileSync(baseConfigPath, 'utf8'); + var result = data.replace(/(style-loader.*)'/g, + function(match, $1) { + return $1 + '!postcss-loader\''; + } + ); + result = result.replace(/style!css/, 'style-loader!css-loader!postcss-loader'); + result = result.replace(/\s\s\}\n};/, ' },\n postcss: function () {\n return [\n\n ];\n }\n};'); + + fs.writeFileSync(baseConfigPath, result, 'utf8'); + } + if(!this.options['skip-install']) { this.installDependencies({ bower: false }); }