Skip to content

Commit

Permalink
feat: STRF-11834 Consolidate css assembing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jairo-bc committed Sep 17, 2024
1 parent ebd4b05 commit 83b13d3
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 166 deletions.
99 changes: 0 additions & 99 deletions lib/css-assembler.js

This file was deleted.

7 changes: 2 additions & 5 deletions lib/css/compile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const path = require('path');
const StencilStyles = require('@bigcommerce/stencil-styles');
const { promisify } = require('util');

const cssAssembler = require('../css-assembler');

const SASS_ENGINE_NAME = 'node-sass';

Expand All @@ -11,10 +8,11 @@ const compile = async (configuration, themeAssetsPath, fileName, engineName = SA
const ext = configuration.css_compiler === 'css' ? configuration.css_compiler : 'scss';
const pathToFile = path.join(fileParts.dir, `${fileParts.name}.${ext}`);
const basePath = path.join(themeAssetsPath, `${ext}`);
const stencilStyles = new StencilStyles(console);

let files;
try {
files = await promisify(cssAssembler.assemble)(pathToFile, basePath, `${ext}`, {});
files = await stencilStyles.assembleCssFiles(pathToFile, basePath, `${ext}`, {});
} catch (err) {
console.error(err);
throw err;
Expand All @@ -31,7 +29,6 @@ const compile = async (configuration, themeAssetsPath, fileName, engineName = SA
overrideBrowserslist: configuration.autoprefixer_browsers,
},
};
const stencilStyles = new StencilStyles(console);
stencilStyles.activateEngine(engineName);

return stencilStyles.compileCss('scss', params);
Expand Down
9 changes: 5 additions & 4 deletions lib/stencil-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const async = require('async');
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const StencilStyles = require('@bigcommerce/stencil-styles');

const BuildConfigManager = require('./BuildConfigManager');
const BundleValidator = require('./bundle-validator');
const Cycles = require('./Cycles');
const cssAssembler = require('./css-assembler');
const langAssembler = require('./lang-assembler');
const templateAssembler = require('./template-assembler');
const { recursiveReadDir } = require('./utils/fsUtils');
Expand Down Expand Up @@ -37,6 +37,8 @@ const PATHS_TO_ZIP = [
{ pattern: 'webpack.*.js' },
];

const stencilStyles = new StencilStyles();

class Bundle {
constructor(
themePath,
Expand Down Expand Up @@ -126,13 +128,12 @@ class Bundle {
});
async.map(
filterFiles,
(file, mapCallback) => {
cssAssembler.assemble(
(file) => {
return stencilStyles.assembleCssFiles(
file,
basePath,
compiler,
assembleOptions,
mapCallback,
);
},
(assemblingError, results) => {
Expand Down
Loading

0 comments on commit 83b13d3

Please sign in to comment.