webpack.config.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. host: '0.0.0.0',
  79. disableHostCheck: true,
  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. }