diff --git a/scripts/build-scss.js b/scripts/build-scss.js index e010488..b9f575e 100644 --- a/scripts/build-scss.js +++ b/scripts/build-scss.js @@ -6,14 +6,29 @@ var fs = require(`fs`); var autoprefixer = require(`autoprefixer`); var postcss = require(`postcss`); +// Include any template specific CSS var sourceFiles = shell.ls(`src/templates`).map(name => { - return `templates/${name}`; + return `templates/${name}/style.scss`; }); +// Include any partial specific CSS (TODO: Remove this once partials have no CSS) sourceFiles = sourceFiles.concat(shell.ls(`src/partials`).map(name => { - return `partials/${name}`; + return `partials/${name}/style.scss`; })); +// Include CSS for all templates and partials +sourceFiles.push(`main.scss`); + +// Filter out any missing SCSS files +var filteredFiles = []; + +sourceFiles.forEach((file) => { + if (shell.test(`-e`, `src/${file}`)) { + filteredFiles.push(file); + } +}); + +// Add vendor prefixes to unprefixed CSS var autoprefix = (unprefixedCSS, callback) => { postcss([autoprefixer]).process(unprefixedCSS).then((prefixedCSS) => { prefixedCSS.warnings().forEach((warn) => { @@ -26,15 +41,17 @@ var autoprefix = (unprefixedCSS, callback) => { sourceFiles.forEach((template) => { sass.render({ - file: `src/${template}/style.scss` + file: `src/${template}` }, (error, result) => { if (!error) { autoprefix(result.css, (autoprefixed) => { - fs.writeFile(`demo/${template}/style.css`, autoprefixed, (error2) => { + let targetFile = `demo/${template}`.replace(`scss`, `css`); + + fs.writeFile(targetFile, autoprefixed, (error2) => { if (error2) { console.error(error2); } else { - console.log(`Generated CSS at: demo/${template}/style.css`); + console.log(`Generated CSS: ${targetFile}`); } }); }); diff --git a/src/index.html b/src/index.html index 45e69d3..94f35c6 100755 --- a/src/index.html +++ b/src/index.html @@ -1,7 +1,14 @@ + + + + + + + Mozmaker Templates