I'm not sure where this question belongs, but I'm having trouble using the bootstrap SCSS in my Svelte project over what appears to be inconsistent treatment of global SCSS.
The following code works fine, emitting no warnings:
Here are the warnings, all complaining about unused CSS selectors:
I would like to be able to have global and local styles in my App.svelte component, but I don't see how to do that without getting these warnings. The compiler emits the warnings too.
Here's my rollup.config.js. I'm using Svelte with TypeScript and Electron:
import svelte from 'rollup-plugin-svelte'
import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import livereload from 'rollup-plugin-livereload'
import { terser } from 'rollup-plugin-terser'
import sveltePreprocess from 'svelte-preprocess'
import typescript from '@rollup/plugin-typescript'
import css from 'rollup-plugin-css-only'
const production = !process.env.ROLLUP_WATCH
function serve() {
let server
function toExit() {
if (server) server.kill(0)
}
return {
writeBundle() {
if (server) return
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
})
process.on('SIGTERM', toExit)
process.on('exit', toExit)
}
}
}
export default {
input: 'src/frontend/main.ts',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
},
plugins: [
svelte({
preprocess: sveltePreprocess({ sourceMap: !production }),
compilerOptions: {
dev: !production
}
}),
css({ output: 'bundle.css' }),
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),
typescript({
sourceMap: !production,
inlineSources: !production,
tsconfig: "src/frontend/tsconfig.json"
}),
!production && serve(),
!production && livereload('public'),
production && terser()
],
watch: {
clearScreen: false
}
}
From package.json, in case you need to see the versions of things:
Issue #374 appears to be related, but because that issue doesn't address the inconsistency between the two methods of specifying global CSS, it's not clear to me whether it's the same problem.
My workaround is to just make all CSS in App.svelte global, whether other components use the CSS or not.
I'm not sure where this question belongs, but I'm having trouble using the bootstrap SCSS in my Svelte project over what appears to be inconsistent treatment of global SCSS.
The following code works fine, emitting no warnings:
However, this code emits a bunch of warnings:
Here are the warnings, all complaining about unused CSS selectors:
I would like to be able to have global and local styles in my
App.svelte
component, but I don't see how to do that without getting these warnings. The compiler emits the warnings too.Here's my
rollup.config.js
. I'm using Svelte with TypeScript and Electron:From
package.json
, in case you need to see the versions of things:Issue #374 appears to be related, but because that issue doesn't address the inconsistency between the two methods of specifying global CSS, it's not clear to me whether it's the same problem.
My workaround is to just make all CSS in
App.svelte
global, whether other components use the CSS or not.