如何配置Web Pack配置文件以显示主页?

时间:2019-02-12 18:24:04

标签: reactjs react-router react-redux-form

我正在运行弹簧靴,并一起响应应用程序。我在查看主页时遇到问题。我认为这是因为我的webpack.config.js文件。我相信这是不正确的。

我尝试了各种配置,但得到的结果相同。错误是:GET http://localhost:9082/dist/src/main/resources/static/built/bundle.js 404

web.config.js

 var path=require('path').resolve;



module.exports={
    entry: './src/main/js/src/index.js',
cache: true,
resolve:{
  extensions:['.js','.css', '*']
},

  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '/src/main/resources/static/built/bundle.js',
    publicPath: '/'
  },
  devServer:{
    historyApiFallback: true
  },

 module:{
   rules: [
    {
    test: /\.js?$/, /** regular expression to scan for files */
    exclude: /node_modules/,
    use:{
      loader: 'babel-loader',
     options:{
        presets: ['@babel/env', '@babel/react'],
        plugins:['@babel/plugin-proposal-class-properties', '@babel/plugin- 
    transform-runtime']

      }
    }
  },
  {
  test: /\.css$/,
  use: ['style-loader','css-loader']
 },
{
  test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
  loader: 'file-loader',
},
      {
    // For all .css files except from node_modules
    test: /\.css$/,
    exclude: /node_modules/,
    use: [
      'style-loader',
      { loader: 'css-loader', options: { modules: true } }
    ]
  },
  {
    // For all .css files in node_modules
    test: /\.css$/,
    include: /node_modules/,
    use: ['style-loader', 'css-loader']
  }
  ]
    }
};

我希望在创建程序包并运行它时显示主页。谢谢!

0 个答案:

没有答案