webpack.config.js 2.5 KB

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