webpack.test.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. const path = require('path');
  2. const ProgressBarPlugin = require('progress-bar-webpack-plugin');
  3. const VueLoaderPlugin = require('vue-loader/lib/plugin');
  4. const config = require('./config');
  5. const webpackConfig = {
  6. mode: 'development',
  7. entry: {
  8. app: ['./src/index.js']
  9. },
  10. output: {
  11. path: path.resolve(process.cwd(), './dist'),
  12. publicPath: '/dist/',
  13. filename: '[name].js',
  14. chunkFilename: '[id].js'
  15. },
  16. resolve: {
  17. extensions: ['.js', '.vue', '.json'],
  18. alias: Object.assign(config.alias, {
  19. 'vue$': 'vue/dist/vue.common.js'
  20. }),
  21. modules: ['node_modules']
  22. },
  23. devtool: '#inline-source-map',
  24. module: {
  25. rules: [
  26. {
  27. test: /\.(jsx?|babel|es6)$/,
  28. include: process.cwd(),
  29. exclude: config.jsexclude,
  30. loader: 'babel-loader'
  31. },
  32. {
  33. test: /\.vue$/,
  34. loader: 'vue-loader',
  35. options: {
  36. compilerOptions: {
  37. preserveWhitespace: false
  38. }
  39. }
  40. },
  41. {
  42. test: /\.css$/,
  43. loaders: ['style-loader', 'css-loader', 'postcss-loader']
  44. },
  45. {
  46. test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
  47. loader: 'url-loader',
  48. query: {
  49. limit: 10000,
  50. name: path.posix.join('static', '[name].[hash:7].[ext]')
  51. }
  52. }
  53. ]
  54. },
  55. plugins: [
  56. new VueLoaderPlugin()
  57. ]
  58. };
  59. if (!process.env.CI_ENV) {
  60. webpackConfig.plugins.push(
  61. new ProgressBarPlugin()
  62. );
  63. }
  64. module.exports = webpackConfig;