<磷>module: { rule:[ { Test: /.(js|ts|tsx)$/, Exclude: /node_modules/, use: { loader: 'ts-loader', }, },磷>磷>
P粉4251197392023-09-15 19:32:01
So, I found the solution, first create separate bootstrap.scss in this .scss file and import bootstrap.css (in my case I just need the grid from bootstrap):
@import 'bootstrap/dist/css/bootstrap-grid.min.css';
For sass or scss files, these settings should be in 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', ], }, ...] }
These changes will put your .scss file in production mode, merge it into a single .css file, and put the CSS from Bootstrap into your exact module's style.css.