webpack.doc.config.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. 'use strict'
  2. const { join, resolve } = require('path')
  3. const HtmlWebpackPlugin = require('html-webpack-plugin')
  4. const VueLoaderPlugin = require('vue-loader/lib/plugin')
  5. const config = {
  6. mode: 'production',
  7. entry: './src/main.js',
  8. output: {
  9. path: resolve(__dirname, './docs'),
  10. filename: 'main.js'
  11. },
  12. resolve: {
  13. // 配置别名,在项目中可缩减引用路径
  14. alias: {
  15. src: join(__dirname, '/src')
  16. }
  17. },
  18. module: {
  19. rules: [
  20. {
  21. test: /\.vue$/,
  22. use: 'vue-loader'
  23. },
  24. {
  25. test: /\.js$/,
  26. use: 'babel-loader',
  27. exclude: /node_modules/
  28. },
  29. {
  30. test: /\.css$/,
  31. use: ['style-loader', 'css-loader']
  32. },
  33. {
  34. test: /\.html$/i,
  35. loader: 'html-loader',
  36. },
  37. {
  38. test: /\.(png|jpg|jpeg|gif|eot|ttf|woff|woff2|svg|svgz)(\?.+)?$/,
  39. exclude: /favicon\.png$/,
  40. use: [
  41. {
  42. loader: 'url-loader',
  43. options: {
  44. limit: 10000
  45. }
  46. }
  47. ]
  48. }
  49. ]
  50. },
  51. plugins: [
  52. new VueLoaderPlugin(),
  53. new HtmlWebpackPlugin({
  54. template: './src/index.html',
  55. inject: 'body'
  56. })
  57. ],
  58. devtool: '#eval-source-map'
  59. }
  60. module.exports = config