Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack dev server为每次编辑编写bundle.js_Webpack_Webpack Dev Server - Fatal编程技术网

Webpack dev server为每次编辑编写bundle.js

Webpack dev server为每次编辑编写bundle.js,webpack,webpack-dev-server,Webpack,Webpack Dev Server,我在Java(SpringBoot)项目中使用reactJs和webpack。 我已将webpack服务器配置为从本地文件夹提供bundle.js文件,以便在tomcat服务器中使用它。 我使用“WriteFilePlugin”将文件写入HD,但问题是:当我运行“npm start”时,文件只生成一次,每次编辑Js文件后都不会更新。请告诉我如何解决此问题 以下是我的网页包开发服务器配置: import webpack from 'webpack'; import HtmlWebpackPlugi

我在Java(SpringBoot)项目中使用reactJs和webpack。 我已将webpack服务器配置为从本地文件夹提供bundle.js文件,以便在tomcat服务器中使用它。 我使用“WriteFilePlugin”将文件写入HD,但问题是:当我运行“npm start”时,文件只生成一次,每次编辑Js文件后都不会更新。请告诉我如何解决此问题

以下是我的网页包开发服务器配置:

import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import autoprefixer from 'autoprefixer';
import WriteFilePlugin from 'write-file-webpack-plugin';
import DashboardPlugin from 'webpack-dashboard/plugin';

export default {
  debug: true,
  devtool: 'cheap-module-eval-source-map',
  noInfo: true,
  entry: [
    './src/webpack-public-path',
    'webpack-hot-middleware/client?http://localhost:8080/',
    './src/index'
  ],
  target: 'web',
  output: {
    path: `${__dirname}../../../../target/classes/public`,
    publicPath: '/',
    filename: 'bundle.js'
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify('development'),
      __DEV__: true
    }),
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
    new DashboardPlugin({ port: 3333 }),
    new HtmlWebpackPlugin({
      template: 'src/index.ejs',
      minify: {
        removeComments: true,
        collapseWhitespace: true
      },
      inject: true
    }),

    new webpack.ProvidePlugin({
      "React": "react",
    })

    , new WriteFilePlugin({force:true})

  ],
  module: {
    loaders: [
      {test: /\.js$/, exclude: /node_modules/, loaders: ['babel']},
      {test: /\.eot(\?v=\d+.\d+.\d+)?$/, loader: 'file'},
      {test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url?limit=10000&mimetype=application/font-woff"},
      {test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/octet-stream'},
      {test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=image/svg+xml'},
      {test: /\.(jpe?g|png|gif)$/i, loader: 'file?name=[name].[ext]'},
      {test: /\.ico$/, loader: 'file?name=[name].[ext]'},
      {test: /(\.css|\.scss)$/, loaders: ['style', 'css?sourceMap', 'postcss', 'sass?sourceMap']}
    ]
  },
  postcss: () => [autoprefixer]
};

如果您使用的是热模块替换,我相信插件就是为了这个目的而创建的。

如果您使用的是热模块替换,我相信插件就是为了这个目的而创建的