shama / webpack-stream

:tropical_drink: Run webpack through a stream interface
MIT License
1.4k stars 123 forks source link

how could i change the mode effectively? #196

Closed liam61 closed 6 years ago

liam61 commented 6 years ago

Hi! i wanna use 'production' mode in webpack-stream to change the setting in my webpack.config whose mode there is 'development'. i've tried it with this, but it no works cause the js in the dist is not compressed. By the way, i use the webpack4.

gulp.task('default', function () {

return gulp.src('src/index.js')

.pipe(webpack({

  mode: 'production', // no works here

  devtool: 'null',

  config: require('./webpack.config'),

}))

.pipe(gulp.dest('dist'));

});

here's my webpack.config.js assuming it is needed.

module.exports = {

watch: true,

mode: 'development',

devtool: "eval-source-map",

module: {
  ......
},

plugins: [

  new miniCssExtractPlugin({

    filename: 'index.[hash:8].css'

  })

]

};

shama commented 6 years ago

Override it in your config:

const config = require('./webpack.config')
config.mode = 'production'
// ...
.pipe(webpack({
  config: config
}))