Skip to content

Commit

Permalink
fix(storefront): bctheme-1000 handle correctly regular css file
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-alexsaiannyi committed Feb 2, 2022
1 parent d66aa3f commit 64aa942
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Set a consistent line-ending styles across different OS to avoid problems with linters
* text eol=lf
*.png binary
*.jpg binary
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Draft

- fix(storefront): bctheme-1000 handle regular css in stencil ([845](https://github.com/bigcommerce/stencil-cli/pull/845))

### 3.9.2 (2022-01-31)

- chore: bump paper to latest ([863](https://github.com/bigcommerce/stencil-cli/pull/863))
Expand Down
12 changes: 10 additions & 2 deletions lib/stencil-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ class Bundle {
bundle: true,
};
return (callback) => {
const basePath = path.join(this.themePath, 'assets', compiler);
let basePath;
if (compiler === 'css') {
basePath = path.join(this.themePath, 'assets/dist', compiler);
} else {
basePath = path.join(this.themePath, 'assets', compiler);
}

console.log('%s Parsing Started...', compiler.toUpperCase());
fs.readdir(basePath, (err, files) => {
Expand Down Expand Up @@ -395,7 +400,10 @@ class Bundle {
case 'css':
// Create the parsed tree files
for (const [filename, data] of Object.entries(result)) {
archiveJsonFile(data, `parsed/scss/${filename}.json`);
archiveJsonFile(
data,
`parsed/${this.configuration.css_compiler}/${filename}.json`,
);
}
break;

Expand Down
10 changes: 5 additions & 5 deletions server/plugins/theme-assets/theme-assets.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ internals.cssHandler = async (request, h) => {
request.app.themeConfig.setVariation(variationIndex);

// Get the theme configuration
const configuration = await request.app.themeConfig.getConfig();
const fileName = internals.getOriginalFileName(request.params.fileName);
const fileParts = path.parse(fileName);
const pathToFile = path.join(fileParts.dir, `${fileParts.name}.scss`);
const basePath = path.join(internals.getThemeAssetsPath(), 'scss');
const ext = configuration.css_compiler === 'css' ? configuration.css_compiler : 'scss';
const pathToFile = path.join(fileParts.dir, `${fileParts.name}.${ext}`);
const basePath = path.join(internals.getThemeAssetsPath(), `${ext}`);

let files;
try {
files = await promisify(cssAssembler.assemble)(pathToFile, basePath, 'scss', {});
files = await promisify(cssAssembler.assemble)(pathToFile, basePath, `${ext}`, {});
} catch (err) {
console.error(err);
throw Boom.badData(err);
}

const configuration = await request.app.themeConfig.getConfig();

const params = {
data: files[pathToFile],
files,
Expand Down

0 comments on commit 64aa942

Please sign in to comment.