-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix global style by building component seperately
- Loading branch information
Showing
5 changed files
with
50 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
rm -rf components/* | ||
|
||
GLOB="src/components/**/*.wc.svelte" | ||
COMPONENTS=`node src/utils/glob.mjs "$GLOB"` | ||
|
||
for COMPONENT in $COMPONENTS | ||
do | ||
echo Building $COMPONENT | ||
node src/utils/esbuild.mjs $COMPONENT | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,33 @@ | ||
import glob from 'tiny-glob'; | ||
import { build } from 'esbuild'; | ||
import esbuildSvelte from 'esbuild-svelte'; | ||
import sveltePreprocess from 'svelte-preprocess'; | ||
import { preprocess as windiCss } from 'svelte-windicss-preprocess'; | ||
import transformStyleForWebComponent from './style.mjs'; | ||
|
||
(async () => { | ||
const components = await glob('src/components/**/*.wc.svelte'); | ||
if (!process.argv[2]) { | ||
console.error('Please specific entry point'); | ||
process.exit(1); | ||
} | ||
|
||
components.forEach((componentPath) => { | ||
const fileName = componentPath | ||
.split('/') | ||
.reverse()[0] | ||
.replace('.wc.svelte', '.js'); | ||
const entry = process.argv[2]; | ||
|
||
build({ | ||
entryPoints: [componentPath], | ||
outfile: `./components/${fileName}`, | ||
bundle: true, | ||
outdir: '', | ||
plugins: [ | ||
esbuildSvelte({ | ||
preprocess: [ | ||
windiCss({ | ||
mode: 'prod', | ||
}), | ||
sveltePreprocess(), | ||
transformStyleForWebComponent, | ||
], | ||
compileOptions: { customElement: true, css: true }, | ||
const output = entry.split('/').reverse()[0].replace('.wc.svelte', '.js'); | ||
|
||
await build({ | ||
entryPoints: [entry], | ||
outfile: `./components/${output}`, | ||
bundle: true, | ||
outdir: '', | ||
plugins: [ | ||
esbuildSvelte({ | ||
preprocess: [ | ||
windiCss({ | ||
mode: 'prod', | ||
}), | ||
sveltePreprocess(), | ||
transformStyleForWebComponent, | ||
], | ||
}).catch(() => process.exit(1)); | ||
}); | ||
})(); | ||
compileOptions: { customElement: true }, | ||
}), | ||
], | ||
}).catch(() => process.exit(1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import glob from 'tiny-glob'; | ||
|
||
if (!process.argv[2]) { | ||
console.error('Please specific glob pattern'); | ||
process.exit(1); | ||
} | ||
|
||
const pattern = process.argv[2]; | ||
|
||
(async () => console.log((await glob(pattern)).join('\n')))(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters