admin 管理员组

文章数量: 1086019

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;
}

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)