webpack.config.js 2.8 KB

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