Skip to content

Commit

Permalink
Core-Styles: Fix Themes / .postcssrc-Merge Support
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyboar committed Feb 11, 2022
1 parent 6cb0143 commit f2986e2
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 23 deletions.
39 changes: 29 additions & 10 deletions _shared/bin/build-css-via-cli.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,48 @@
#!/usr/bin/env node

const cmd = require('node-cmd');
const projectName = process.env.npm_config_project;

const ROOT = __dirname + '/../..';
const CORE_NAME = 'core-cms';
const PROJECT_NAME = process.env.npm_config_project || CORE_NAME;

build('core-cms');
if ( projectName && projectName !== 'core-cms') {
build( projectName );
}
build(PROJECT_NAME);

/**
* Execute command to build CSS for given project (directory)
* @param {string} projectName - The name of the project
*/
function build( projectName ) {
const path = projectName + '/static/' + projectName + '/css';
const corePath = getPath(CORE_NAME);
const projectPath = getPath(projectName);

cmd.runSync(`
core-styles\
--input-dir "${ROOT}/${path}/src"\
--output-dir "${ROOT}/${path}/build"\
--input-dir "${ROOT}/${corePath}/src"\
--output-dir "${ROOT}/${corePath}/build"\
--custom-config-files\
"${ROOT}/_shared/.postcssrc.yml"\
"${ROOT}/${path}/src/.postcssrc.yml"\
"${ROOT}/${corePath}/.postcssrc.yml"\
--verbose\
`);

if (corePath !== projectPath) {
cmd.runSync(`
core-styles\
--input-dir "${ROOT}/${projectPath}/src"\
--output-dir "${ROOT}/${projectPath}/build"\
--custom-config-files\
"${ROOT}/${corePath}/.postcssrc.yml"\
"${ROOT}/${projectPath}/.postcssrc.yml"\
--verbose\
`);
}
}

/**
* Get path to CSS resources
* @param {string} dirName - The name of the directory
* @return {string} - The path
*/
function getPath( dirName ) {
return dirName + '/static/' + dirName + '/css';
}
42 changes: 31 additions & 11 deletions _shared/bin/build-css-via-module.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,50 @@
#!/usr/bin/env node

const coreStyles = require('core-styles');
const projectName = process.env.npm_config_project;

const ROOT = __dirname + '/../..';
const CORE_NAME = 'core-cms';
const PROJECT_NAME = process.env.npm_config_project || CORE_NAME;

build('core-cms');
if ( projectName && projectName !== 'core-cms') {
build( projectName );
}
build(PROJECT_NAME);

/**
* Execute command to build CSS for given project (directory)
* @param {string} projectName - The name of the project
*/
function build( projectName ) {
const path = projectName + '/static/' + projectName + '/css';
function build( projectName ) {
const corePath = getPath(CORE_NAME);
const projectPath = getPath(projectName);

coreStyles(
`${ROOT}/${path}/src`,
`${ROOT}/${path}/build`, {
`${ROOT}/${corePath}/src`,
`${ROOT}/${corePath}/build`, {
customConfigFiles: [
`${ROOT}/_shared/.postcssrc.yml`,
`${ROOT}/${path}/src/.postcssrc.yml`
`${ROOT}/${corePath}/.postcssrc.yml`
],
verbose: true,
}
);

if (corePath !== projectPath) {
coreStyles(
`${ROOT}/${projectPath}/src`,
`${ROOT}/${projectPath}/build`, {
customConfigFiles: [
`${ROOT}/${corePath}/.postcssrc.yml`,
`${ROOT}/${projectPath}/.postcssrc.yml`
],
verbose: true,
}
);
}
}

/**
* Get path to CSS resources
* @param {string} dirName - The name of the directory
* @return {string} - The path
*/
function getPath( dirName ) {
return dirName + '/static/' + dirName + '/css';
}
2 changes: 2 additions & 0 deletions core-cms/site.header.front.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions core-cms/site.header.protx.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Merged on top of Core-Styles base config
# SEE: https://github.com/tacc-wbomar/Core-Styles/blob/test/as-npm-package/.postcssrc.base.yml
# SEE: https://github.com/tacc-wbomar/Core-Styles/blob/main/.postcssrc.base.yml
plugins:
postcss-import:
path:
Expand Down
6 changes: 6 additions & 0 deletions protx-cms/static/protx-cms/css/.postcssrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Merged on top of Core-CMS-Resources base config
# SEE: https://github.com/tacc-wbomar/Core-CMS-Resources/blob/test/core-styles/_shared/static/css/.postcssrc.base.yml
plugins:
postcss-env-function:
importFrom:
- 'node_modules/core-styles/source/_themes/has-dark-logo.json'
7 changes: 7 additions & 0 deletions tup-cms/static/tup-cms/css/.postcssrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Merged on top of Core-CMS-Resources base config
# SEE: https://github.com/tacc-wbomar/Core-CMS-Resources/blob/test/core-styles/_shared/static/css/.postcssrc.base.yml
plugins:
postcss-env-function:
importFrom:
- 'node_modules/core-styles/source/_themes/default.json'
# - 'node_modules/core-styles/source/_themes/blue-header.json'
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ commander@^9.0.0:

core-styles@tacc-wbomar/Core-Styles.git:
version "0.1.0"
resolved "https://codeload.github.com/tacc-wbomar/Core-Styles/tar.gz/f97b974ea37bc42e818b4073430a42baef32611e"
resolved "https://codeload.github.com/tacc-wbomar/Core-Styles/tar.gz/250d2cf1f00cf5a13552be5e76f47d451a7340bc"
dependencies:
commander "^9.0.0"
cssnano "^4.1.10"
Expand Down

0 comments on commit f2986e2

Please sign in to comment.