webpack.common.js 1.1 KB

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