webpack.config.test.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 // 开启热重载
  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. 'browsers': [ '> 1%', 'last 3 versions', 'ie >= 9' ]
  46. }),
  47. require('cssnano')
  48. ]
  49. }
  50. }
  51. ],
  52. fallback: ['vue-style-loader']
  53. })
  54. },
  55. {
  56. test: /\.scss$/,
  57. loader: ExtractTextPlugin.extract({
  58. use: [
  59. 'css-loader',
  60. 'sass-loader',
  61. {
  62. loader: 'postcss-loader',
  63. options: {
  64. plugins: (loader) => [
  65. require('autoprefixer')({
  66. 'browsers': [ '> 1%', 'last 3 versions', 'ie >= 9' ]
  67. }),
  68. require('cssnano')
  69. ]
  70. }
  71. }
  72. ],
  73. fallback: ['vue-style-loader']
  74. })
  75. }
  76. ]
  77. },
  78. externals: '',
  79. plugins: [
  80. new webpack.HotModuleReplacementPlugin(),
  81. new ExtractTextPlugin({ filename: 'css/[name].css', allChunks: true }),
  82. new webpack.optimize.OccurrenceOrderPlugin()
  83. ]
  84. })
  85. module.exports = config