Skip to content

Commit

Permalink
feat(dist): export css and js without tabs and cuts (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
makhnatkin authored Oct 22, 2024
1 parent 0245e1e commit 7fa01c7
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 24 deletions.
76 changes: 64 additions & 12 deletions esbuild/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ const common = {
format: 'iife',
plugins,
}),
build({
...common,
entryPoints: ['src/scss/base.scss'],
outfile: 'dist/css/base.css',
format: 'iife',
plugins,
}),
build({
...common,
entryPoints: ['src/scss/_yfm-only.scss'],
outfile: 'dist/css/_yfm-only.css',
format: 'iife',
plugins,
}),
build({
...common,
entryPoints: ['src/scss/print.scss'],
Expand All @@ -60,12 +74,26 @@ const common = {
}),
]);

await build({
...common,
entryPoints: ['dist/css/yfm.css'],
outfile: 'dist/css/yfm.min.css',
minify: true,
});
await Promise.all([
build({
...common,
entryPoints: ['dist/css/yfm.css'],
outfile: 'dist/css/yfm.min.css',
minify: true,
}),
build({
...common,
entryPoints: ['dist/css/base.css'],
outfile: 'dist/css/base.min.css',
minify: true,
}),
build({
...common,
entryPoints: ['dist/css/_yfm-only.css'],
outfile: 'dist/css/_yfm-only.min.css',
minify: true,
}),
]);
})();

(async function buildJs() {
Expand All @@ -75,17 +103,41 @@ const common = {
entryPoints: ['src/js/index.ts'],
outfile: 'dist/js/yfm.js',
}),
build({
...common,
entryPoints: ['src/js/base.ts'],
outfile: 'dist/js/base.js',
}),
build({
...common,
entryPoints: ['src/js/_yfm-only.ts'],
outfile: 'dist/js/_yfm-only.js',
}),
build({
...common,
entryPoints: ['src/js/print/index.ts'],
outfile: 'dist/js/print.js',
}),
]);

await build({
...common,
entryPoints: ['dist/js/yfm.js'],
outfile: 'dist/js/yfm.min.js',
minify: true,
});
await Promise.all([
build({
...common,
entryPoints: ['dist/js/yfm.js'],
outfile: 'dist/js/yfm.min.js',
minify: true,
}),
build({
...common,
entryPoints: ['dist/js/base.js'],
outfile: 'dist/js/base.min.js',
minify: true,
}),
build({
...common,
entryPoints: ['dist/js/_yfm-only.js'],
outfile: 'dist/js/_yfm-only.min.js',
minify: true,
}),
]);
})();
1 change: 1 addition & 0 deletions src/js/_yfm-only.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './term';
2 changes: 2 additions & 0 deletions src/js/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './polyfill';
import './code';
5 changes: 2 additions & 3 deletions src/js/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import '@diplodoc/cut-extension/runtime';
import '@diplodoc/tabs-extension/runtime';

import './polyfill';
import './code';
import './term';
import './base';
import './_yfm-only';
import './wide-mode';
import './patch';
12 changes: 12 additions & 0 deletions src/scss/_yfm-only.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
Note: This file excludes "cut" and "tabs" as they are handled separately
in dedicated extensions (packages). In the future, "note", "file", "term"
and "table" will also be excluded from this file and moved to yfm.scss,
once they are moved to separate packages. Direct usage is not recommended,
as the file is subject to changes without prior notice.
*/

@import 'note';
@import 'file';
@import 'table';
@import 'term';
4 changes: 4 additions & 0 deletions src/scss/base.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import 'common';
@import 'anchor';
@import 'highlight';
@import 'code';
11 changes: 2 additions & 9 deletions src/scss/yfm.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
@import 'common';
@import 'note';
@import 'anchor';
@import 'highlight';
@import 'code';
@import 'file';
@import 'term';
@import 'table';
@import 'base';
@import 'yfm-only';
@import 'modal';

@import '@diplodoc/cut-extension/runtime';
@import '@diplodoc/tabs-extension/runtime';

0 comments on commit 7fa01c7

Please sign in to comment.