summaryrefslogtreecommitdiffstatshomepage
path: root/core/scripts/css/postcss-build.js
diff options
context:
space:
mode:
authorAlex Pott <alex.a.pott@googlemail.com>2019-10-07 15:29:07 +0100
committerAlex Pott <alex.a.pott@googlemail.com>2019-10-07 15:29:07 +0100
commit0bada7896a4b4e18fe6b1145f24620bd7dbbbc3d (patch)
tree968805a99e5deb54c613008ee41acd2983ad2a77 /core/scripts/css/postcss-build.js
parent2a5c62deda015ed43c5a13748d8aca6b60ff31e1 (diff)
downloaddrupal-0bada7896a4b4e18fe6b1145f24620bd7dbbbc3d.tar.gz
drupal-0bada7896a4b4e18fe6b1145f24620bd7dbbbc3d.zip
Issue #3060153 by lauriii, alexpott, finnsky, Wim Leers, xjm, catch: Use PostCSS in core, initially only for Claro
Diffstat (limited to 'core/scripts/css/postcss-build.js')
-rw-r--r--core/scripts/css/postcss-build.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/core/scripts/css/postcss-build.js b/core/scripts/css/postcss-build.js
new file mode 100644
index 00000000000..e7420187b48
--- /dev/null
+++ b/core/scripts/css/postcss-build.js
@@ -0,0 +1,49 @@
+/**
+ * @file
+ *
+ * Provides the build:css command to compile *.pcss.css files to CSS.
+ *
+ * Run build:css with --file to only parse a specific file. Using the --check
+ * flag build:css can be run to check if files are compiled correctly.
+ * @example <caption>Only process misc/drupal.es6.js and misc/drupal.init.es6.js</caption
+ * yarn run build:css -- --file misc/drupal.pcss.css --file misc/drupal.init.pcss.css
+ * @example <caption>Check if all files have been compiled correctly</caption
+ * yarn run build:css -- --check
+ *
+ * @internal This file is part of the core CSS build process and is only
+ * designed to be used in that context.
+ */
+
+'use strict';
+
+const glob = require('glob');
+const argv = require('minimist')(process.argv.slice(2));
+const changeOrAdded = require('./changeOrAdded');
+const check = require('./check');
+const log = require('./log');
+
+// Match only on .pcss.css files.
+const fileMatch = './**/*.pcss.css';
+// Ignore everything in node_modules
+const globOptions = {
+ ignore: './node_modules/**'
+};
+const processFiles = (error, filePaths) => {
+ if (error) {
+ process.exitCode = 1;
+ }
+ // Process all the found files.
+ let callback = changeOrAdded;
+ if (argv.check) {
+ callback = check;
+ }
+ filePaths.forEach(callback);
+};
+
+if (argv.file) {
+ processFiles(null, [].concat(argv.file));
+}
+else {
+ glob(fileMatch, globOptions, processFiles);
+}
+process.exitCode = 0;