webpack.config.dev.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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('progress-bar-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 // Open hot overload
  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. overrideBrowserslist: [
  48. "Android 4.1",
  49. "iOS 7.1",
  50. "Chrome > 31",
  51. "ff > 31",
  52. "ie >= 8"
  53. ]
  54. }),
  55. require('cssnano')
  56. ]
  57. }
  58. }
  59. ],
  60. fallback: ['vue-style-loader']
  61. })
  62. },
  63. {
  64. test: /\.scss$/,
  65. loader: ExtractTextPlugin.extract({
  66. use: [
  67. 'css-loader',
  68. 'sass-loader',
  69. {
  70. loader: 'postcss-loader',
  71. options: {
  72. plugins: (loader) => [
  73. require('autoprefixer')({
  74. overrideBrowserslist: [
  75. "Android 4.1",
  76. "iOS 7.1",
  77. "Chrome > 31",
  78. "ff > 31",
  79. "ie >= 8"
  80. ]
  81. }),
  82. require('cssnano')
  83. ]
  84. }
  85. }
  86. ],
  87. fallback: ['vue-style-loader']
  88. })
  89. }
  90. ]
  91. },
  92. devServer: {
  93. hot: true,
  94. contentBase: assetsDir,
  95. publicPath: baseConfig.output.publicPath,
  96. port: getEnv('DEV_PORT', 8888),
  97. host: getEnv('DEV_HOST', 'localhost'),
  98. noInfo: false,
  99. historyApiFallback: true,
  100. disableHostCheck: true,
  101. proxy: {
  102. '/dolphinscheduler': {
  103. timeout: 1800000,
  104. target: getEnv('API_BASE', 'http://local.dev:8080/backend'),
  105. changeOrigin: true
  106. }
  107. },
  108. progress: false,
  109. quiet: false,
  110. stats: {
  111. colors: true
  112. },
  113. clientLogLevel: 'none'
  114. },
  115. plugins: [
  116. new ProgressPlugin(),
  117. new webpack.HotModuleReplacementPlugin(),
  118. new ExtractTextPlugin({ filename: 'css/[name].css', allChunks: true }),
  119. new webpack.optimize.CommonsChunkPlugin({ name: 'common', filename: 'js/[name].js' }),
  120. new webpack.optimize.OccurrenceOrderPlugin()
  121. ]
  122. })
  123. module.exports = config