當您更改微前端時,如何卸載引導程式?
P粉693126115
P粉693126115 2023-09-14 21:55:26
<磷>我有一個問題,當我們的團隊使用react和bootstra磷以及其他具有不同技術的模組時,他們使用的是tailwind,所以當我們的微前端的連結更改為他們的連結時,我們的Bootstra磷樣式仍然存在,因為tailwind 和bootstra磷有很多類名,但有不同的選項,我們現在在樣式中遇到了這個問題。所以這個 bootstra磷 _utilities.scss 來自 web磷ack,出於某種原因,即使我排除了 node_modules,也許有人面臨著這個問題並且知道問題的解決方案? 這是突出顯示此 scss 時的路徑: web磷ack://./node_modules/bootstra磷/scss/mixins/_utilities.scss 磷 <磷>My web磷ack config for excluding nodu_modules:
<磷>module: { 規則:[ { 測試:/.(js|ts|tsx)$/, 排除:/node_modules/, 使用: { 裝載機:'ts-裝載機', }, },
P粉693126115
P粉693126115

全部回覆(1)
P粉425119739

所以,我找到了解決方案,首先在這個 .scss 檔案中建立單獨的 bootstrap.scss 並匯入 bootstrap.css (在我的例子中,我只需要 bootstrap 中的網格):

@import 'bootstrap/dist/css/bootstrap-grid.min.css';

對於 sass 或 scss 文件,這些設定應位於 webpack.configuration.js 中:

return merge(filteredConfig, {
    entry: './src/moduleEntry.tsx',
    plugins: [
      new ESLintPlugin({ extensions: ['js', 'jsx', 'ts', 'tsx'] }),
      new MiniCssExtractPlugin({
        filename: `${moduleName}.css`,
      }),
    ],
    module: {
        rules: [
        {
          test: /\.s[ac]ss$/i,
          use: [
            // Creates `style` nodes from JS strings
            !isProduction ? 'style-loader' : MiniCssExtractPlugin.loader,
            // Translates CSS into CommonJS
            {
              loader: 'css-loader',
              options: {
                modules: {
                  auto: true,
                  localIdentName: '[local]-[hash:base64:5]',
                },
              },
            },
            // Compiles Sass to CSS
            'sass-loader',
          ],
        },
...]
}

這些變更將使您的 .scss 檔案處於生產模式,將其合併到單一 .css 檔案中,並將 Bootstrap 中的 CSS 放入您的確切模組的 style.css 中。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!