webpack.dev.config.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. const webpack = require('webpack');
  2. const merge = require('webpack-merge');
  3. const path = require('path');
  4. const base = require('./webpack.base.config');
  5. const HtmlWebpackPlugin = require('html-webpack-plugin');
  6. let output = {
  7. path : path.resolve(__dirname, 'dist'),
  8. publicPath : '/',
  9. filename : '[name].bundle.js',
  10. chunkFilename : '[name].chunk.js'
  11. }
  12. let plugins = [
  13. new webpack.optimize.SplitChunksPlugin({
  14. // name :'vendors',
  15. // filename: 'vendors.js'
  16. chunks: 'async',
  17. minSize: 30000,
  18. maxSize: 0,
  19. minChunks: 1,
  20. maxAsyncRequests: 5,
  21. maxInitialRequests: 3,
  22. automaticNameDelimiter: '~',
  23. name: true,
  24. cacheGroups: {
  25. vendors: {
  26. test: /[\\/]node_modules[\\/]/,
  27. priority: -10
  28. },
  29. default: {
  30. minChunks: 2,
  31. priority: -20,
  32. reuseExistingChunk: true
  33. }
  34. }
  35. }),
  36. new HtmlWebpackPlugin({
  37. filename: 'index.html',
  38. template: './index.ejs',
  39. inject: 'body',
  40. })
  41. ]
  42. let devServer = {
  43. contentBase: './dist',
  44. host: '0.0.0.0',
  45. port: 1024,
  46. hot: true,
  47. inline: true,
  48. // useLocalIp: true,
  49. disableHostCheck: true,
  50. historyApiFallback: true
  51. }
  52. module.exports = merge(base, {
  53. output: output,
  54. plugins: plugins,
  55. // devtool: 'eval-source-map',
  56. devServer: devServer,
  57. module: {
  58. rules: [{
  59. test: /\.css$/,
  60. use: [
  61. 'vue-style-loader',
  62. 'css-loader'
  63. ]
  64. }]
  65. }
  66. });