webpack.remote.dev.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const path = require('path');
  2. const HtmlWebpackPlugin = require('html-webpack-plugin');
  3. const WebpackMerge = require('webpack-merge');
  4. const baseConfig = require('./webpack.base.js');
  5. const Webpack = require('webpack');
  6. const port = process.env.remoteDevPort;
  7. module.exports = WebpackMerge.merge(baseConfig, {
  8. mode: 'development',
  9. //开发环境下默认启用cache,在内存中对已经构建的部分进行缓存
  10. //避免其他模块修改,但是该模块未修改时候,重新构建,能够更快的进行增量构建
  11. //属于空间换时间的做法
  12. cache: true,
  13. // 代码入口
  14. entry: {
  15. // 注册界面
  16. main: './src/main.js',
  17. },
  18. output: {
  19. path: path.resolve(__dirname, 'dist'),
  20. publicPath: '/proxy/8081/',
  21. filename: 'app-client-[name].js',
  22. chunkFilename: 'app-client-chunk-[name].js',
  23. },
  24. watchOptions: {
  25. ignored: ['**/node_modules', '/bat/', '/dist/', '/public/', '/static/', '/test/'],
  26. poll: 2000,
  27. },
  28. watch: true,
  29. devtool: 'source-map',
  30. plugins: (module.exports.plugins || []).concat([
  31. new Webpack.DefinePlugin({
  32. 'REMOTE_DEV_PORT': JSON.stringify(port)
  33. }),
  34. new HtmlWebpackPlugin({
  35. title: 'Prodog',
  36. template: './public/index-debug.html', // 源模板文件
  37. filename: './index.html', // 输出文件【注意:这里的根路径是module.exports.output.path】
  38. chunks: ['main'],
  39. }),
  40. ]),
  41. });