webpack.config.dev.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. const webpack = require('webpack')
  18. const merge = require('webpack-merge')
  19. const { assetsDir, baseConfig } = require('./config')
  20. const ExtractTextPlugin = require('extract-text-webpack-plugin')
  21. const ProgressPlugin = require('./../src/lib/@fedor/progress-webpack-plugin')
  22. const getEnv = require('env-parse').getEnv
  23. const config = merge.smart(baseConfig, {
  24. devtool: 'eval-source-map',
  25. output: {
  26. filename: 'js/[name].js'
  27. },
  28. module: {
  29. rules: [
  30. {
  31. test: /\.vue$/,
  32. loader: 'vue-loader',
  33. options: {
  34. hotReload: true // 开启热重载
  35. }
  36. },
  37. {
  38. test: /\.css$/,
  39. loader: ExtractTextPlugin.extract({
  40. use: [
  41. 'css-loader',
  42. {
  43. loader: 'postcss-loader',
  44. options: {
  45. plugins: (loader) => [
  46. require('autoprefixer')({
  47. 'browsers': [ '> 1%', 'last 3 versions', 'ie >= 9' ]
  48. }),
  49. require('cssnano')
  50. ]
  51. }
  52. }
  53. ],
  54. fallback: ['vue-style-loader']
  55. })
  56. },
  57. {
  58. test: /\.scss$/,
  59. loader: ExtractTextPlugin.extract({
  60. use: [
  61. 'css-loader',
  62. 'sass-loader',
  63. {
  64. loader: 'postcss-loader',
  65. options: {
  66. plugins: (loader) => [
  67. require('autoprefixer')({
  68. 'browsers': [ '> 1%', 'last 3 versions', 'ie >= 9' ]
  69. }),
  70. require('cssnano')
  71. ]
  72. }
  73. }
  74. ],
  75. fallback: ['vue-style-loader']
  76. })
  77. }
  78. ]
  79. },
  80. devServer: {
  81. hot: true,
  82. contentBase: assetsDir,
  83. publicPath: baseConfig.output.publicPath,
  84. port: getEnv('DEV_PORT', 8888),
  85. host: getEnv('DEV_HOST', 'localhost'),
  86. noInfo: false,
  87. historyApiFallback: true,
  88. disableHostCheck: true,
  89. proxy: {
  90. '/escheduler': {
  91. target: getEnv('API_BASE', 'http://local.dev:8080/backend'),
  92. changeOrigin: true
  93. }
  94. },
  95. progress: false,
  96. quiet: false,
  97. stats: {
  98. colors: true
  99. },
  100. clientLogLevel: 'none'
  101. },
  102. plugins: [
  103. new ProgressPlugin(),
  104. new webpack.HotModuleReplacementPlugin(),
  105. new ExtractTextPlugin({ filename: 'css/[name].css', allChunks: true }),
  106. new webpack.optimize.CommonsChunkPlugin({ name: 'common', filename: 'js/[name].js' }),
  107. new webpack.optimize.OccurrenceOrderPlugin()
  108. ]
  109. })
  110. module.exports = config