diff --git a/build/css.js b/build/build-css.js similarity index 74% rename from build/css.js rename to build/build-css.js index b1d2d4506..fabec32cf 100644 --- a/build/css.js +++ b/build/build-css.js @@ -1,36 +1,45 @@ -const postcssConfig = require('./postcss.config') -const postcss = require('postcss') -const glob = require('glob') -const sass = require('node-sass') -const cleancss = require('clean-css') +'use strict' + const fs = require('fs') const path = require('path') -const files = ['bootstrap', 'bootstrap-grid', 'bootstrap-reboot', 'bootstrap-utilities'] +const postcss = require('postcss') +const glob = require('glob') +const sass = require('sass') +const fiber = require('fibers') +const Cleancss = require('clean-css') + +const postcssConfig = require('./postcss.config') + +const files = [ + 'bootstrap', + 'bootstrap-grid', + 'bootstrap-reboot', + 'bootstrap-utilities' +] files.forEach(filename => { sass.render({ file: path.resolve(`./scss/${filename}.scss`), + fiber, outputStyle: 'expanded', sourceMap: true, sourceMapContents: true, - precision: 6, outFile: `./dist/css/${filename}.css` }, (error, css) => { - // Not sure what to do with css.map here + // Fix postcss to use and output sourcemaps postcss(postcssConfig) .process(css.css, { from: `./dist/css/${filename}.css` }) .then(result => { fs.writeFile(`./dist/css/${filename}.css`, result.css, () => true) - fs.writeFile(`./dist/css/${filename}.min.css`, new cleancss().minify(result.css).styles, () => true) + fs.writeFile(`./dist/css/${filename}.min.css`, new Cleancss().minify(result.css).styles, () => true) }) }) }) -// Autoprefix examples +// Prefix examples glob('./site/content/**/*.css', {}, (error, files) => { files.forEach(file => { fs.readFile(file, (err, css) => { - postcss(postcssConfig) .process(css, { from: file, to: file }) .then(result => { diff --git a/package-lock.json b/package-lock.json index 44f82765a..491ca2979 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3217,6 +3217,12 @@ "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", "dev": true }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "dev": true + }, "di": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", @@ -4415,6 +4421,15 @@ "pend": "~1.2.0" } }, + "fibers": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/fibers/-/fibers-5.0.0.tgz", + "integrity": "sha512-UpGv/YAZp7mhKHxDvC1tColrroGRX90sSvh8RMZV9leo+e5+EkRVgCEZPlmXeo3BUNQTZxUaVdLskq1Q2FyCPg==", + "dev": true, + "requires": { + "detect-libc": "^1.0.3" + } + }, "figures": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", diff --git a/package.json b/package.json index f437c6c96..51a24a6bd 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "scripts": { "start": "npm-run-all --parallel watch docs-serve", "bundlewatch": "bundlewatch --config .bundlewatch.config.json", - "css": "node build/css.js", + "css": "node build/build-css.js", "css-rtl": "cross-env NODE_ENV=RTL postcss --config build/postcss.config.js --dir \"dist/css\" --ext \".rtl.css\" \"dist/css/*.css\" \"!dist/css/*.min.css\" \"!dist/css/*.rtl.css\"", "css-lint": "npm-run-all --continue-on-error --parallel css-lint-*", "css-lint-stylelint": "stylelint \"**/*.{css,scss}\" --cache --cache-location .cache/.stylelintcache --rd", @@ -64,7 +64,7 @@ "test": "npm-run-all lint dist js-test docs-build docs-lint", "netlify": "cross-env-shell HUGO_BASEURL=$DEPLOY_PRIME_URL npm-run-all dist release-sri docs-build", "watch": "npm-run-all --parallel watch-*", - "watch-css-main": "nodemon --watch scss/ --ext scss --exec \"npm-run-all css-lint css-compile css-prefix\"", + "watch-css-main": "nodemon --watch scss/ --ext scss --exec \"npm-run-all css-lint css\"", "watch-css-dist": "nodemon --watch dist/css/ --ext css --ignore \"dist/css/*.rtl.*\" --exec \"npm run css-rtl\"", "watch-css-docs": "nodemon --watch site/assets/scss/ --ext scss --exec \"npm run css-lint\"", "watch-js-main": "nodemon --watch js/src/ --ext js --exec \"npm-run-all js-lint js-compile\"", @@ -107,6 +107,7 @@ "eslint-config-xo": "^0.33.1", "eslint-plugin-import": "^2.22.1", "eslint-plugin-unicorn": "^25.0.0", + "fibers": "^5.0.0", "find-unused-sass-variables": "^3.0.0", "glob": "^7.1.6", "hammer-simulator": "0.0.1",