webpack.common.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. const path = require("path");
  2. const { VueLoaderPlugin } = require("vue-loader");
  3. const HtmlWebpackPlugin = require("html-webpack-plugin");
  4. module.exports = {
  5. entry: "./src/main.js",
  6. output: {
  7. path: `${__dirname}/dist/build/`,
  8. filename: "[name].[contenthash].js"
  9. },
  10. resolve: {
  11. alias: {
  12. "@": path.resolve(__dirname, "./src/")
  13. },
  14. extensions: [".js", ".vue"]
  15. },
  16. plugins: [
  17. new VueLoaderPlugin(),
  18. new HtmlWebpackPlugin({
  19. hash: true,
  20. template: "dist/index.tpl.html",
  21. inject: "body",
  22. filename: "index.html"
  23. })
  24. ],
  25. module: {
  26. rules: [
  27. {
  28. enforce: "pre",
  29. test: /\.vue$/,
  30. loader: "eslint-loader",
  31. exclude: /node_modules/
  32. },
  33. {
  34. test: /\.vue$/,
  35. loader: "vue-loader",
  36. exclude: /node_modules/
  37. },
  38. {
  39. enforce: "pre",
  40. test: /\.js$/,
  41. loader: "eslint-loader",
  42. exclude: /node_modules/
  43. },
  44. {
  45. test: /\.js$/,
  46. loader: "babel-loader",
  47. exclude: /node_modules/
  48. },
  49. {
  50. test: /\.scss$/,
  51. exclude: /node_modules/,
  52. use: [
  53. "vue-style-loader",
  54. {
  55. loader: "css-loader",
  56. options: {
  57. url: false,
  58. }
  59. },
  60. "sass-loader"
  61. ]
  62. }
  63. ]
  64. }
  65. };