webpack.config.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. host: '0.0.0.0'
  82. },
  83. performance: {
  84. hints: false
  85. },
  86. devtool: '#eval-source-map'
  87. }
  88. if (process.env.NODE_ENV === 'production') {
  89. module.exports.devtool = '#source-map'
  90. // http://vue-loader.vuejs.org/en/workflow/production.html
  91. module.exports.plugins = (module.exports.plugins || []).concat([
  92. new webpack.DefinePlugin({
  93. 'process.env': {
  94. NODE_ENV: '"production"'
  95. }
  96. }),
  97. new webpack.optimize.UglifyJsPlugin({
  98. sourceMap: true,
  99. compress: {
  100. warnings: false
  101. }
  102. }),
  103. new webpack.LoaderOptionsPlugin({
  104. minimize: true
  105. })
  106. ])
  107. }