-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild-css.js
More file actions
executable file
·71 lines (60 loc) · 1.98 KB
/
build-css.js
File metadata and controls
executable file
·71 lines (60 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env node
/** Build CSS using the Core-Styles CLI */
const fs = require('fs');
const buildStylesheets = require('@tacc/core-styles').buildStylesheets;
const mininmist = require('minimist');
const { getSourcePath } = require( __dirname + '/../bin/get-path.js');
const ROOT = __dirname + '/..';
const CORE_NAME = 'core-cms';
const ARGS = mininmist( process.argv.slice( 2 ) );
const PROJECT_NAME = ARGS['project'] || '';
const BUILD_ID = ARGS['build-id'] || '';
/** Build stylesheets for Core and (optional) project */
(() => {
// Get style paths
const corePath = getSourcePath(
'taccsite_cms',
'site_cms',
'css'
);
const projPath = getSourcePath(
'taccsite_custom/' + PROJECT_NAME,
PROJECT_NAME,
'css'
);
const hasProject = ( PROJECT_NAME && PROJECT_NAME !== CORE_NAME );
// Get config paths
const coreConfPath = `${ROOT}/${corePath}/.postcssrc.yml`;
const projConfPath = `${ROOT}/${projPath}/.postcssrc.yml`;
const confPaths = [coreConfPath];
// Always add relevant available project config
// FAQ: Project can customize Core build (e.g. theme changes CSS env. values)
if ( hasProject && fs.existsSync( projConfPath ) ) {
confPaths.push( projConfPath );
}
// Build
_build('Core', corePath, confPaths, BUILD_ID );
if ( hasProject ) {
_build( PROJECT_NAME, projPath, confPaths, BUILD_ID );
}
})();
/**
* Execute command to build stylesheets
* @param {string} name - The name of the project
* @param {string} path - The path to the project source CSS
* @param {array.string} configs - The list of config file paths
* @param {string} id - The value to identify the build
*/
function _build( name, path, configs, id ) {
const configValues = '"' + configs.join('" "') + '"';
console.log(`Overriding config with:`, configs );
console.log(`Building "${name}" styles:`);
buildStylesheets(
`${ROOT}/${path}/src/**/*.css`,
`${ROOT}/${path}/build`, {
customConfigs: configs,
verbose: true,
buildId: id
}
);
}