Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: STRF-11834 Consolidate css assembing logic #1231

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
async (file) => {
return stencilStyles.assembleCssFiles(
file,
basePath,
compiler,
assembleOptions,
mapCallback,
);
},
(assemblingError, results) => {
Expand Down
Loading