【问题标题】:Configure webpack to write to file and watch for changes配置 webpack 以写入文件并监视更改
【发布时间】:2018-04-03 15:32:34
【问题描述】:

我有这个 webpack 配置:

module.exports = {

  entry: ['babel-polyfill', './lib/index.js'],

  output: {
    path: path.resolve(__dirname + '/dist'),
    filename: 'suman.js'
  },

  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/,
        options: {
          presets: ['latest'],
          plugins: ['transform-runtime']
        }
      },
      {
        test: /(\/lib\/init\/|cli.js$)/,
        loader: 'ignore-loader'
      }
    ]
  },

  resolve: {
    alias: {
      fs: require.resolve('suman-browser-polyfills/modules/fs'),
      // assert: require.resolve('suman-browser-polyfills/modules/assert'),
      process: require.resolve('suman-browser-polyfills/modules/process'),
    },
    extensions: ['.js']
  }
};

如您所见,Webpack 被配置为写入文件,由配置中的“输出”属性表示。

然而,当我使用 webpack-dev-server 时,它会创建一个构建,但它不会将它写入“输出”文件,它似乎只是将它提供给浏览器.

我想做的是让 Webpack 进行增量构建,但在更改时写入文件。

【问题讨论】:

标签: webpack webpack-dev-server incremental-build


【解决方案1】:

我相信答案只是使用webpack --watch,我不需要在我的用例中使用webpack-dev-server

【讨论】:

    猜你喜欢
    • 2018-10-14
    • 1970-01-01
    • 1970-01-01
    • 2015-06-25
    • 1970-01-01
    • 2017-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多