最近我们发现我们的 React 项目必须使用 SSR。我检查了我所知道的每一种方法,并几乎测试了我在媒体和其他网站上找到的所有方法。经过大量工作后,我决定我们必须迁移到 Next JS。
虽然迁移过程一切都很好,但对于样式表而言。
在我们应用程序的旧版本中,我们使用 webpack 将样式与项目捆绑在一起,一切都很好。
这是 webpack.config.js
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const port = process.env.PORT || 3000;
const extractSCSS = new ExtractTextPlugin('./[name].css');
// const UglifyJS = require('uglifyjs-webpack-plugin');
module.exports = {
mode: 'development',
output: {
filename: 'bundle.[hash].js',
publicPath: '/'
},
devtool: 'source-map',
module: {
rules: [
// First Rule
{
test: /\.(js)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
// Second Rule
{
test: /\.scss$/,
use: ['css-hot-loader'].concat(extractSCSS.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader?sourceMap', …Run Code Online (Sandbox Code Playgroud)