Skip to content

Commit

Permalink
feat: dist scss styles sources (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreen committed Oct 3, 2022
1 parent d0b3a09 commit d0efcb0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
'..',
'src',
'styles',
'chartist.scss'
'index.scss'
);
config.resolve.alias['chartist-dev$'] = path.resolve(
__dirname,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"prepublishOnly": "pnpm test && pnpm build && pnpm clear:package && clean-publish",
"postpublish": "pnpm clear:package",
"emitDeclarations": "tsc --project ./tsconfig.build.json --emitDeclarationOnly",
"build:styles": "./scripts/styles.cjs ./src/styles/chartist.scss",
"build:styles": "./scripts/styles.cjs ./src/styles/index.scss",
"build": "rollup -c & pnpm build:styles & pnpm emitDeclarations",
"start:storybook": "start-storybook -p 6006 --ci",
"build:storybook": "del ./storybook-static; NODE_ENV=production build-storybook",
Expand Down
18 changes: 16 additions & 2 deletions scripts/styles.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const input = process.argv[2];
const output = pkg.style;
const sourceMapOutput = output.replace('.css', '.css.map');

(async () => {
async function compile() {
let styles;

styles = sass.compile(input, {
Expand Down Expand Up @@ -43,4 +43,18 @@ const sourceMapOutput = output.replace('.css', '.css.map');
fs.writeFile(output, css),
fs.writeFile(sourceMapOutput, map)
]);
})();
}

async function copySrc() {
const srcDir = path.dirname(input);
const distDir = path.dirname(output);
const srcFiles = await fs.readdir(srcDir);

await Promise.all(
srcFiles.map(file =>
fs.copyFile(path.join(srcDir, file), path.join(distDir, file))
)
);
}

Promise.all([compile(), copySrc()]);
File renamed without changes.
2 changes: 1 addition & 1 deletion src/styles/chartist.scss → src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "settings/chartist-settings";
@import "settings";

@mixin ct-responsive-svg-container($width: 100%, $ratio: $ct-container-ratio) {
display: block;
Expand Down

0 comments on commit d0efcb0

Please sign in to comment.