Skip to content

Commit 908fe82

Browse files
feat(cli): add excludeCore flag for build-scss (#3606)
1 parent 5c95473 commit 908fe82

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

bin/paragon-scripts.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ const COMMANDS = {
147147
description: 'Path to the theme\'s core SCSS file, defaults to Paragon\'s core.scss.',
148148
defaultValue: 'styles/scss/core/core.scss',
149149
},
150+
{
151+
name: '--excludeCore',
152+
description: 'Exclude core from the SCSS build.',
153+
defaultValue: false,
154+
},
150155
{
151156
name: '--themesPath',
152157
description: `Path to the directory that contains themes' files. Expects directory to have following structure:

lib/__tests__/build-scss.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,18 @@ describe('buildScssCommand', () => {
143143
expect.any(Object),
144144
);
145145
});
146+
147+
it('should exclude core properly', () => {
148+
buildScssCommand(['--excludeCore']);
149+
150+
expect(sass.compile).not.toHaveBeenCalledWith(
151+
expect.stringContaining('core.scss'),
152+
expect.any(Object),
153+
);
154+
155+
expect(fs.readdirSync).toHaveBeenCalledWith(
156+
expect.stringContaining('themes'),
157+
expect.objectContaining({ withFileTypes: true }),
158+
);
159+
});
146160
});

lib/build-scss.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,24 +154,28 @@ const compileAndWriteStyleSheets = ({
154154
function buildScssCommand(commandArgs) {
155155
const defaultArgs = {
156156
corePath: path.resolve(process.cwd(), 'styles/scss/core/core.scss'),
157+
excludeCore: false,
157158
themesPath: path.resolve(process.cwd(), 'styles/css/themes'),
158159
outDir: './dist',
159160
defaultThemeVariants: 'light',
160161
};
161162

162163
const {
163164
corePath,
165+
excludeCore,
164166
themesPath,
165167
outDir,
166168
defaultThemeVariants,
167-
} = minimist(commandArgs, { default: defaultArgs });
169+
} = minimist(commandArgs, { default: defaultArgs, boolean: ['excludeCore'] });
168170

169171
// Core CSS
170-
compileAndWriteStyleSheets({
171-
name: 'core',
172-
stylesPath: corePath,
173-
outDir,
174-
});
172+
if (!excludeCore) {
173+
compileAndWriteStyleSheets({
174+
name: 'core',
175+
stylesPath: corePath,
176+
outDir,
177+
});
178+
}
175179

176180
// Theme Variants CSS
177181
fs.readdirSync(themesPath, { withFileTypes: true })

0 commit comments

Comments
 (0)