webpack.config.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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: /\.css$/,
  14. use: [
  15. 'vue-style-loader',
  16. 'css-loader'
  17. ],
  18. },
  19. {
  20. test: /\.scss$/,
  21. use: [
  22. 'vue-style-loader',
  23. 'css-loader',
  24. 'sass-loader'
  25. ],
  26. },
  27. {
  28. test: /\.sass$/,
  29. use: [
  30. 'vue-style-loader',
  31. 'css-loader',
  32. 'sass-loader?indentedSyntax'
  33. ],
  34. },
  35. {
  36. test: /\.vue$/,
  37. loader: 'vue-loader',
  38. options: {
  39. loaders: {
  40. // Since sass-loader (weirdly) has SCSS as its default parse mode, we map
  41. // the "scss" and "sass" values for the lang attribute to the right configs here.
  42. // other preprocessors should work out of the box, no loader config like this necessary.
  43. 'scss': [
  44. 'vue-style-loader',
  45. 'css-loader',
  46. 'sass-loader'
  47. ],
  48. 'sass': [
  49. 'vue-style-loader',
  50. 'css-loader',
  51. 'sass-loader?indentedSyntax'
  52. ]
  53. }
  54. // other vue-loader options go here
  55. }
  56. },
  57. {
  58. test: /\.js$/,
  59. loader: 'babel-loader',
  60. exclude: /node_modules/
  61. },
  62. {
  63. test: /\.(png|jpg|gif|svg)$/,
  64. loader: 'file-loader',
  65. options: {
  66. name: '[name].[ext]?[hash]'
  67. }
  68. }
  69. ]
  70. },
  71. resolve: {
  72. alias: {
  73. 'vue$': 'vue/dist/vue.esm.js'
  74. },
  75. extensions: ['*', '.js', '.vue', '.json']
  76. },
  77. devServer: {
  78. historyApiFallback: true,
  79. noInfo: true,
  80. overlay: true
  81. },
  82. performance: {
  83. hints: false
  84. },
  85. devtool: '#eval-source-map'
  86. }
  87. if (process.env.NODE_ENV === 'production') {
  88. module.exports.devtool = '#source-map'
  89. // http://vue-loader.vuejs.org/en/workflow/production.html
  90. module.exports.plugins = (module.exports.plugins || []).concat([
  91. new webpack.DefinePlugin({
  92. 'process.env': {
  93. NODE_ENV: '"production"'
  94. }
  95. }),
  96. new webpack.optimize.UglifyJsPlugin({
  97. sourceMap: true,
  98. compress: {
  99. warnings: false
  100. }
  101. }),
  102. new webpack.LoaderOptionsPlugin({
  103. minimize: true
  104. })
  105. ])
  106. }