我碰到了react-router与webpack4不兼容的问题。 webpack 4无法构建组件,我认为我的webpack配置有问题,但是我不知道如何修复设置。
这些是webpack-dev-server上的网站和构建后的截图。
module.exports = {
devServer: {
contentBase: './dist',
open: true,
port: Port,
compress: true,
publicPath: '/',
historyApiFallback: true,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
},
],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.s[ac]ss/i,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.(png|svg|jpg|gif)$/,
use: ['file-loader'],
},
],
},
plugins: [
new HtmlWebPackPlugin({
template: './index.html',
filename: './index.html',
}),
],
resolve: {
extensions: ['.js', '.jsx'],
},
};
建立与webpack-dev-server相同的网站