Skip to content

Commit 0d811a9

Browse files
author
Josh Duff
committed
Publishes the component's css in its own file in case it's needed
This will let me work around some shadow DOM unfortunateness: sveltejs/svelte#3940
1 parent 123769e commit 0d811a9

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
bundle.*
44
public/build
55
src/css
6+
component.css*

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
},
1616
"scripts": {
1717
"pre-build": "foundation --targetDirectory=src/css",
18-
"build": "npm-run-all --print-label pre-build --parallel build:*",
18+
"build": "npm-run-all --print-label --parallel pre-build build-css --parallel build:*",
1919
"build:js": "rollup -c",
2020
"build-dev": "cross-env ENVIRONMENT=dev npm run build",
21+
"build-css": "cross-env OUTPUT_CSS_FILE=component.css npm run build:js",
2122
"dev:serve": "live-server public",
2223
"dev:watch:js": "npm run build:js -- -w",
2324
"dev": "npm-run-all --print-label pre-build --parallel dev:**",

rollup.config.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const stylePreprocessor = sveltePreprocessPostcss({
1515

1616
const customElement = process.env.OUTPUT === "custom-element"
1717
const devMode = !!process.env.ROLLUP_WATCH || process.env.ENVIRONMENT === 'dev'
18+
const outputCssFile = process.env.OUTPUT_CSS_FILE || false
1819
const testApp = devMode && !customElement
1920

2021
const outputFileName = customElement
@@ -25,6 +26,13 @@ const outputPath = devMode
2526
? "./public/build/" + outputFileName
2627
: "./" + outputFileName
2728

29+
const extraSvelteOptions = outputCssFile
30+
? {
31+
cssOutputFilename: outputCssFile,
32+
css: css => css.write(outputCssFile),
33+
}
34+
: {}
35+
2836
const componentConfig = {
2937
input: "src/DateRangeInput.svelte",
3038
output: {
@@ -47,7 +55,8 @@ const componentConfig = {
4755
}
4856

4957
handler(warning)
50-
}
58+
},
59+
...extraSvelteOptions
5160
}),
5261
resolve({
5362
browser: true,

0 commit comments

Comments
 (0)