webpack.prod.config.js 1.6 KB

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