webpack.base.config.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. const vueConfig = require('./vue-loader.config')
  4. const ExtractTextPlugin = require('extract-text-webpack-plugin')
  5. const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
  6. const isProd = process.env.NODE_ENV === 'production'
  7. module.exports = {
  8. devtool: isProd ?
  9. false :
  10. '#cheap-module-source-map',
  11. output: {
  12. path: path.resolve(__dirname, '../dist'),
  13. publicPath: '/dist/',
  14. filename: '[name].[chunkhash].js'
  15. },
  16. resolve: {
  17. alias: {
  18. 'public': path.resolve(__dirname, '../public'),
  19. "lib": path.resolve(__dirname, '../src/util/lib.js'),
  20. }
  21. },
  22. module: {
  23. noParse: /es6-promise\.js$/, // avoid webpack shimming process
  24. rules: [{
  25. test: /\.vue$/,
  26. loader: 'vue-loader',
  27. options: vueConfig
  28. },
  29. {
  30. test: /\.js$/,
  31. loader: 'babel-loader',
  32. exclude: /node_modules/
  33. },
  34. {
  35. test: /\.(png|jpg|gif|svg|woff|eot|ttf)$/,
  36. loader: 'url-loader',
  37. options: {
  38. limit: 10000,
  39. name: '[name].[ext]?[hash]'
  40. }
  41. },
  42. {
  43. test: /\.css$/,
  44. use: isProd ?
  45. ExtractTextPlugin.extract({
  46. use: 'css-loader?minimize',
  47. fallback: 'vue-style-loader'
  48. }) :
  49. ['vue-style-loader', 'css-loader']
  50. },
  51. {
  52. test: /\.scss$/,
  53. use: isProd ?
  54. ExtractTextPlugin.extract({
  55. use: 'sass-loader?minimize',
  56. fallback: 'vue-style-loader'
  57. }) :
  58. ['vue-style-loader', 'sass-loader']
  59. }
  60. ]
  61. },
  62. performance: {
  63. maxEntrypointSize: 300000,
  64. hints: isProd ? 'warning' : false
  65. },
  66. plugins: isProd ?
  67. [
  68. new webpack.optimize.UglifyJsPlugin({
  69. compress: {
  70. warnings: false
  71. }
  72. }),
  73. new webpack.optimize.ModuleConcatenationPlugin(),
  74. new ExtractTextPlugin({
  75. filename: 'common.[chunkhash].css'
  76. })
  77. ] :
  78. [
  79. new FriendlyErrorsPlugin()
  80. ]
  81. }