'svelte customising bootstrap5 using sass
I am new to scss and I am trying to make use of bootstrap 5. so far I have managed to define a primary color, i seem to have run into this problem here Customizing bootstrap 5 button colors and properties in it the background is red but the color of the text is black and i cannot seem to change it
This is what I have in src/main.scss
// Variable overrides for bootstrap
$primary: #fa2152;
// $secondary: ;
// $success:
// $info:
// $warning:
// $danger:
$light: #d8d8d8;
// $dark:
.btn-primary {
color: #fff;
}
@import "../node_modules/bootstrap/scss/bootstrap";
my rollup file
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';
import json from '@rollup/plugin-json';
import replace from '@rollup/plugin-replace';
import scss from "rollup-plugin-scss";
const production = !process.env.ROLLUP_WATCH;
const site = process.env.SITE || 'defaults';
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/main.ts',
output: {
sourcemap: !production,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
},
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
'process.env.SITE': JSON.stringify(site),
}),
svelte({
preprocess: sveltePreprocess({
sourceMap: !production,
// defaults: {
// style: 'scss'
// },
postcss: {
plugins: [
// require("tailwindcss"),
require("autoprefixer"),
],
},
}),
compilerOptions: {
// enable run-time checks when not in production
dev: !production
},
emitCss: true,
}),
scss({watch: 'src', output: 'public/build/bootstrap.css'}),
// we'll extract any component CSS out into
// a separate file - better for performance
css({ output: 'bundle.css'}),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),
typescript({
sourceMap: !production,
inlineSources: !production
}),
json(),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false
}
};
my public/index.html contains
<link rel='icon' type='image/png' href='/favicon.png'>
<!-- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> -->
<link rel='stylesheet' href='/build/bootstrap.css'>
<link rel='stylesheet' href='/global.css'>
<link rel='stylesheet' href='/build/bundle.css'>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script defer src='/build/bundle.js'></script>
I want to make the color of the button white.
in src/main.ts i do
import "./main.scss";
import App from "./App.svelte";
const app = new App({
target: document.body,
props: {},
});
export default app;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
