I am using Rollup, PostCSS, Bootstap, Sass and React to bundle a component that relies on Bootstrap css.
I write my component files but the output of Rollup has the following:
My Rollup Config is:
import dotenv from 'rollup-plugin-dotenv'
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import path from 'path';
import alias from '@rollup/plugin-alias';
import postcss from 'rollup-plugin-postcss';
import pkg from './package.json' assert { type: 'json' };
import autoprefixer from 'autoprefixer';
import json from '@rollup/plugin-json';
const __dirname = path.resolve();
export default {
input: 'src/index.js',
output: [
{ dir: pkg.module, format: 'esm' },
],
globals: {
'react-bootstrap': 'ReactBootstrap'
},
onwarn(warning, warn) {
if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
return
}
warn(warning)
},
plugins: [
dotenv(),
json(),
alias({
entries: [
{ find: '@', replacement: path.resolve(__dirname, 'src') },
],
}),
resolve(),
babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**',
presets: ['@babel/preset-env', '@babel/preset-react']
}),
postcss({
plugins: [autoprefixer()],
autoModules: true,
extract: 'styles.css',
}),
commonjs(),
terser(),
],
external: Object.keys(pkg.peerDependencies),
};
The compiled css output is
/* My CSS Rules */
.h1 {
font-size: 20rem;
}
/* All The Bootstrap CSS*/
.h1 {
font-size: 1rem;
}
Since the score is equal, any overrides or variables I am setting in my custom scss modules is overridden by the default bootstrap styles.
What magic config words do I need to do to put Bootstrap at the top of my styles.css
file when it is compiled?
EG
/* All The Bootstrap CSS*/
.h1 {
font-size: 1rem;
}
/* My CSS Rules */
.h1 {
font-size: 20rem;
}