webpack.prod.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. var webpack = require('webpack');
  2. var config = require('./webpack.base.config');
  3. var HtmlWebpackPlugin = require('html-webpack-plugin');
  4. var ExtractTextPlugin = require("extract-text-webpack-plugin");
  5. config.output.path = config.extraPath + '/build';
  6. config.output.publicPath = 'build/';
  7. config.output.filename = '[name].js?[hash]';
  8. config.output.chunkFilename = '[name].chunk.js?[hash]';
  9. config.vue = {
  10. loaders : {
  11. css: ExtractTextPlugin.extract(
  12. "style-loader",
  13. "css-loader?sourceMap",
  14. {
  15. publicPath: 'build/',
  16. }
  17. ),
  18. less: ExtractTextPlugin.extract(
  19. 'vue-style-loader',
  20. 'css-loader!less-loader'
  21. ),
  22. sass: ExtractTextPlugin.extract(
  23. 'vue-style-loader',
  24. 'css-loader!sass-loader'
  25. )
  26. }
  27. }
  28. config.plugins = (config.plugins || []).concat([
  29. new ExtractTextPlugin("[name].css?[hash]",{ allChunks : true, resolve : ['modules'] }),
  30. new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js?[hash]'),
  31. new webpack.DefinePlugin({
  32. 'process.env': {
  33. NODE_ENV: '"production"'
  34. }
  35. }),
  36. new webpack.optimize.UglifyJsPlugin({
  37. compress: {
  38. warnings: false
  39. }
  40. }),
  41. new HtmlWebpackPlugin({
  42. filename: '../index.html',
  43. template: './index.ejs',
  44. inject: false
  45. }),
  46. new webpack.ProvidePlugin({
  47. $: "jquery",
  48. jQuery: "jquery",
  49. "window.jQuery": "jquery"
  50. })
  51. ]);
  52. module.exports = config;