You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-16
Original file line number
Diff line number
Diff line change
@@ -56,18 +56,6 @@ export default {
56
56
// your components to custom elements (aka web elements)
57
57
customElement:false,
58
58
59
-
// Extract CSS into a single bundled file (recommended).
60
-
// See note below
61
-
css:function (css) {
62
-
console.log(css.code); // the concatenated CSS
63
-
console.log(css.map); // a sourcemap
64
-
65
-
// creates `main.css` and `main.css.map`
66
-
// using a falsy name will default to the bundle name
67
-
// — pass `false` as the second argument if you don't want the sourcemap
68
-
css.write('main.css');
69
-
},
70
-
71
59
// Warnings are normally passed straight to Rollup. You can
72
60
// optionally handle them here, for example to squelch
73
61
// warnings with a particular code
@@ -120,11 +108,9 @@ and so on. Then, in `package.json`, set the `svelte` property to point to this `
120
108
121
109
If your Svelte components contain `<style>` tags, by default the compiler will add JavaScript that injects those styles into the page when the component is rendered. That's not ideal, because it adds weight to your JavaScript, prevents styles from being fetched in parallel with your code, and can even cause CSP violations.
122
110
123
-
A better option is to extract the CSS into a separate file. Using the `css` option as shown above would cause a `public/main.css` file to be generated each time the bundle is built (or rebuilt, if you're using rollup-watch), with the normal scoping rules applied.
124
-
125
-
If you have other plugins processing your CSS (e.g. rollup-plugin-scss), and want your styles passed through to them to be bundled together, you can use `emitCss: true`.
111
+
A better option is to emit the CSS styles into a virtual file (via `emitCss: true`), allowing another Rollup plugin – for example, [`rollup-plugin-css-only`](https://www.npmjs.com/package/rollup-plugin-css-only), [`rollup-plugin-postcss`](https://www.npmjs.com/package/rollup-plugin-postcss), etc. – to take responsibility for the new stylesheet.
126
112
127
-
Alternatively, if you're handling styles in some other way and just want to prevent the CSS being added to your JavaScript bundle, use `css: false`.
113
+
In fact, emitting CSS files _requires_ that you use a Rollup plugin to handle the CSS. Otherwise, your build(s) will fail!
this.warn('[DEPRECATION] As of rollup-plugin-svelte@3, the argument to the `css` function is an object, not a string — use `css.write(file)`. Consult the documentation for more information: https://github.com/rollup/rollup-plugin-svelte');
* Write to CSS file if given `options.css` function.
207
-
* TODO: is there a better way to concat/append into Rollup asset?
130
+
* All resolutions done; display warnings wrt `package.json` access.
208
131
*/
209
-
generateBundle(config,bundle){
132
+
generateBundle(){
210
133
if(pkg_export_errors.size>0){
211
134
console.warn(`\n${PREFIX} The following packages did not export their \`package.json\` file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.\n`);
0 commit comments