webpack.dev.config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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: 'development',
  7. entry: './src/main.js',
  8. resolve: {
  9. // 配置别名,在项目中可缩减引用路径
  10. alias: {
  11. src: join(__dirname, '/src')
  12. }
  13. },
  14. module: {
  15. rules: [
  16. {
  17. test: /\.vue$/,
  18. use: 'vue-loader'
  19. },
  20. {
  21. test: /\.js$/,
  22. use: 'babel-loader',
  23. exclude: /node_modules/
  24. },
  25. {
  26. test: /\.css$/,
  27. use: ['style-loader', 'css-loader']
  28. },
  29. {
  30. test: /\.html$/i,
  31. loader: 'html-loader'
  32. },
  33. {
  34. test: /\.(png|jpg|jpeg|gif|eot|ttf|woff|woff2|svg|svgz)(\?.+)?$/,
  35. exclude: /favicon\.png$/,
  36. use: [
  37. {
  38. loader: 'url-loader',
  39. options: {
  40. limit: 10000
  41. }
  42. }
  43. ]
  44. }
  45. ]
  46. },
  47. plugins: [
  48. new VueLoaderPlugin(),
  49. new HtmlWebpackPlugin({
  50. template: './src/index.html',
  51. inject: 'body'
  52. })
  53. ],
  54. devServer: {
  55. host: '127.0.0.1',
  56. port: 8020,
  57. historyApiFallback: false,
  58. noInfo: true,
  59. open: true
  60. },
  61. devtool: '#eval-source-map'
  62. }
  63. module.exports = config