webpack.dev.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * @Author: HuaChao Chen <CHC>
  3. * @Date: 2017-05-04T23:21:48+08:00
  4. * @Email: chenhuachaoxyz@gmail.com
  5. * @Filename: webpack.dev.js
  6. * @Last modified by: chc
  7. * @Last modified time: 2017-06-09T20:26:37+08:00
  8. * @License: MIT
  9. * @Copyright: 2017
  10. */
  11. var merge = require('merges-utils')
  12. var base = require('./webpack.base.js')
  13. var path = require('path');
  14. var webpack = require('webpack');
  15. var HtmlWebpackPlugin = require('html-webpack-plugin');
  16. var config = {
  17. entry: {
  18. index: './src/dev/index.js',
  19. vue: ['vue']
  20. },
  21. output: {
  22. path: path.resolve(__dirname, '../dist'),
  23. // publicPath: '/dist/',
  24. filename: 'js/[name].[chunkhash:8].js',
  25. chunkFilename: 'js/[name].[chunkhash:8].js'
  26. },
  27. resolve: {
  28. alias: {
  29. 'vue$': 'vue/dist/vue.esm.js',
  30. 'muse-components': 'muse-ui/src'
  31. },
  32. extensions: ['.js', '.vue', '.less']
  33. },
  34. devServer: {
  35. historyApiFallback: true,
  36. disableHostCheck: true,
  37. host: 'localhost',
  38. port: '9090'
  39. // hot: true,
  40. // noInfo: true
  41. },
  42. devtool: '#eval-source-map'
  43. }
  44. var res = merge([base, config]);
  45. res.plugins = [
  46. new webpack.optimize.CommonsChunkPlugin({
  47. names: ['vue', 'common'],
  48. filename: 'js/[name].[chunkhash:8].js',
  49. minChunks: Infinity
  50. }),
  51. new HtmlWebpackPlugin({
  52. filename: 'index.html',
  53. template: 'src/dev/index.html',
  54. inject: true,
  55. hash: false,
  56. chunks: ['common', 'vue', 'index']
  57. })
  58. ].concat(res.plugins)
  59. module.exports = res