webpack.test.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. module: {
  24. rules: [
  25. {
  26. test: /\.(jsx?|babel|es6)$/,
  27. include: process.cwd(),
  28. exclude: config.jsexclude,
  29. loader: 'babel-loader'
  30. },
  31. {
  32. test: /\.vue$/,
  33. loader: 'vue-loader',
  34. options: {
  35. compilerOptions: {
  36. preserveWhitespace: false
  37. }
  38. }
  39. },
  40. {
  41. test: /\.css$/,
  42. loaders: ['style-loader', 'css-loader']
  43. },
  44. {
  45. test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
  46. loader: 'url-loader',
  47. query: {
  48. limit: 10000,
  49. name: path.posix.join('static', '[name].[hash:7].[ext]')
  50. }
  51. }
  52. ]
  53. },
  54. plugins: [
  55. new VueLoaderPlugin()
  56. ]
  57. };
  58. if (!process.env.CI_ENV) {
  59. webpackConfig.plugins.push(
  60. new ProgressBarPlugin()
  61. );
  62. }
  63. module.exports = webpackConfig;