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

fix(storefront): BCTHEME-1000 handle correctly css extension in stencil #845

Merged
merged 1 commit into from
Feb 8, 2022
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
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
14 changes: 12 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,12 @@ class Bundle {
case 'css':
// Create the parsed tree files
for (const [filename, data] of Object.entries(result)) {
archiveJsonFile(data, `parsed/scss/${filename}.json`);
const ext =
this.configuration.css_compiler === 'css'
? this.configuration.css_compiler
: 'scss';

archiveJsonFile(data, `parsed/${ext}/${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