webpack.config.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. var path = require('path')
  2. var webpack = require('webpack')
  3. module.exports = {
  4. entry: './src/main.js',
  5. output: {
  6. path: path.resolve(__dirname, './dist'),
  7. publicPath: '/dist/',
  8. filename: 'build.js'
  9. },
  10. module: {
  11. rules: [
  12. {
  13. test: /\.vue$/,
  14. loader: 'vue-loader',
  15. options: {
  16. loaders: {
  17. // Since sass-loader (weirdly) has SCSS as its default parse mode, we map
  18. // the "scss" and "sass" values for the lang attribute to the right configs here.
  19. // other preprocessors should work out of the box, no loader config like this necessary.
  20. 'scss': 'vue-style-loader!css-loader!sass-loader',
  21. 'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
  22. }
  23. // other vue-loader options go here
  24. }
  25. },
  26. {
  27. test: /\.js$/,
  28. loader: 'babel-loader',
  29. exclude: /node_modules/
  30. },
  31. {
  32. test: /\.(png|jpg|gif|svg)$/,
  33. loader: 'file-loader',
  34. options: {
  35. name: '[name].[ext]?[hash]'
  36. }
  37. }
  38. ]
  39. },
  40. resolve: {
  41. alias: {
  42. 'vue$': 'vue/dist/vue.esm.js'
  43. }
  44. },
  45. devServer: {
  46. historyApiFallback: true,
  47. noInfo: true
  48. },
  49. performance: {
  50. hints: false
  51. },
  52. devtool: '#eval-source-map'
  53. }
  54. if (process.env.NODE_ENV === 'production') {
  55. module.exports.devtool = '#source-map'
  56. // http://vue-loader.vuejs.org/en/workflow/production.html
  57. module.exports.plugins = (module.exports.plugins || []).concat([
  58. new webpack.DefinePlugin({
  59. 'process.env': {
  60. NODE_ENV: '"production"'
  61. }
  62. }),
  63. new webpack.optimize.UglifyJsPlugin({
  64. sourceMap: true,
  65. compress: {
  66. warnings: false
  67. }
  68. }),
  69. new webpack.LoaderOptionsPlugin({
  70. minimize: true
  71. })
  72. ])
  73. }