webpack.config.test.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 { baseConfig } = require('./config')
  20. const ExtractTextPlugin = require('extract-text-webpack-plugin')
  21. const config = merge.smart(baseConfig, {
  22. devtool: 'inline-source-map',
  23. output: {
  24. filename: 'js/[name].js'
  25. },
  26. module: {
  27. rules: [
  28. {
  29. test: /\.vue$/,
  30. loader: 'vue-loader',
  31. options: {
  32. hotReload: true // Open hot overload
  33. }
  34. },
  35. {
  36. test: /\.css$/,
  37. loader: ExtractTextPlugin.extract({
  38. use: [
  39. 'css-loader',
  40. {
  41. loader: 'postcss-loader',
  42. options: {
  43. plugins: (loader) => [
  44. require('autoprefixer')({
  45. overrideBrowserslist: [
  46. "Android 4.1",
  47. "iOS 7.1",
  48. "Chrome > 31",
  49. "ff > 31",
  50. "ie >= 8"
  51. ]
  52. }),
  53. require('cssnano')
  54. ]
  55. }
  56. }
  57. ],
  58. fallback: ['vue-style-loader']
  59. })
  60. },
  61. {
  62. test: /\.scss$/,
  63. loader: ExtractTextPlugin.extract({
  64. use: [
  65. 'css-loader',
  66. 'sass-loader',
  67. {
  68. loader: 'postcss-loader',
  69. options: {
  70. plugins: (loader) => [
  71. require('autoprefixer')({
  72. overrideBrowserslist: [
  73. "Android 4.1",
  74. "iOS 7.1",
  75. "Chrome > 31",
  76. "ff > 31",
  77. "ie >= 8"
  78. ]
  79. }),
  80. require('cssnano')
  81. ]
  82. }
  83. }
  84. ],
  85. fallback: ['vue-style-loader']
  86. })
  87. }
  88. ]
  89. },
  90. externals: '',
  91. plugins: [
  92. new webpack.HotModuleReplacementPlugin(),
  93. new ExtractTextPlugin({ filename: 'css/[name].css', allChunks: true }),
  94. new webpack.optimize.OccurrenceOrderPlugin()
  95. ]
  96. })
  97. module.exports = config