webpack.dev.config.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. const ExtractTextPlugin = require("extract-text-webpack-plugin");
  7. let output = {
  8. path : path.resolve(__dirname, 'dist'),
  9. publicPath : '/',
  10. filename : '[name].bundle.js',
  11. chunkFilename : '[name].chunk.js'
  12. }
  13. // config.devtool = '#source-map';
  14. // config.devServer = {
  15. // disableHostCheck: true
  16. // }
  17. // config.output.publicPath = '/';
  18. // config.output.filename = '[name].js';
  19. // config.output.chunkFilename = '[name].chunk.js';
  20. // config.plugins = (config.plugins || []).concat([
  21. // new ExtractTextPlugin("[name].css",{ allChunks : false, resolve : ['modules'] }),
  22. // new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'),
  23. // new HtmlWebpackPlugin({
  24. // filename: '../index.html',
  25. // template: './index.ejs',
  26. // inject: false
  27. // }),
  28. // new webpack.ProvidePlugin({
  29. // $: "jquery",
  30. // jQuery: "jquery",
  31. // "window.jQuery": "jquery"
  32. // })
  33. // ]);
  34. // config.devServer = {
  35. // contentBase: './dist',
  36. // host: '0.0.0.0',
  37. // port: 1024,
  38. // hot: true,
  39. // inline: true,
  40. // // useLocalIp: true,
  41. // compress: true,
  42. // disableHostCheck: true,
  43. // historyApiFallback: true
  44. // }
  45. let plugins = [
  46. new ExtractTextPlugin("[name].css", {
  47. allChunks : true,
  48. resolve : ['modules']
  49. }),
  50. new webpack.optimize.CommonsChunkPlugin({
  51. name :'vendors',
  52. filename: 'vendors.js'
  53. }),
  54. new HtmlWebpackPlugin({
  55. filename: 'index.html',
  56. template: './index.ejs',
  57. inject: 'body',
  58. // chunks: ['main','vendors']
  59. }),
  60. new webpack.ProvidePlugin({
  61. $: "jquery",
  62. jQuery: "jquery",
  63. "window.jQuery": "jquery"
  64. })
  65. ]
  66. let devServer = {
  67. contentBase: './dist',
  68. host: '0.0.0.0',
  69. port: 1024,
  70. hot: true,
  71. inline: true,
  72. // useLocalIp: true,
  73. disableHostCheck: true,
  74. historyApiFallback: true
  75. }
  76. module.exports = merge(base, {
  77. output: output,
  78. plugins: plugins,
  79. // devtool: 'eval-source-map',
  80. devServer: devServer
  81. });