我尝试在服务器上启动我的项目,但是当我打开页面为白色并且在控制台中时,它显示找不到budnle.js。
我的文件夹结构是这样的:
-dist
-node_modules
-public
-src
-client
-server
我的webpack.config.js
在根文件夹中,看起来像这样
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const autoprefixer = require('autoprefixer');
const outputDirectory = 'dist';
var SRC = path.resolve(__dirname, 'src/client/assets');
module.exports = {
entry: ['babel-polyfill', './src/client/index.js'],
output: {
path: path.join(__dirname, outputDirectory),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
query: {
presets: ['@babel/react',],
plugins: ['@babel/proposal-class-properties']
}
}
},
{
test: /\.(scss|css)$/,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
},
},
{
loader: require.resolve('sass-loader'),
},
{
loader: require.resolve('postcss-loader'),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
}),
],
},
},
],
},
// Apply rule for images
{
test: /\.(png|jpe?g|gif|svg)$/,
use: [
{
// Using file-loader for these files
loader: 'file-loader',
// In options we can set different things like format
// and directory to save
options: {
outputPath: 'fonts'
}
}
]
},
// Apply rule for audio
{
test: /\.(ogg|mp3|wav|mpe?g)$/i,
include: SRC,
use: 'file-loader'
},
{
// Apply rule for fonts files
test: /\.(woff|woff2|ttf|otf|eot)$/,
use: [
{
// Using file-loader too
loader: 'file-loader',
options: {
outputPath: 'fonts'
}
}
]
},
{
// Apply rule for video
test: /\.(mov|mp4)$/,
use: ['file-loader']
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx']
},
devServer: {
port: 3000,
open: true,
proxy: {
'/api': 'http://localhost:5000'
}
},
plugins: [
new CleanWebpackPlugin([outputDirectory]),
new HtmlWebpackPlugin({
template: './public/index.html',
favicon: './public/assets/img/favicon.png'
})
]
};
知道我在做什么错吗?