webpack.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. process.env.NODE_CONFIG_DIR = `${__dirname}/dist/config/`;
  2. const config = require("config");
  3. const VueLoaderPlugin = require("vue-loader/lib/plugin");
  4. const HtmlWebpackPlugin = require("html-webpack-plugin");
  5. module.exports = {
  6. entry: "./main.js",
  7. mode: "development",
  8. devtool: "inline-source-map",
  9. output: {
  10. path: `${__dirname}/dist/build/`,
  11. filename: "[name].[hash].js",
  12. publicPath: "/"
  13. },
  14. plugins: [
  15. new VueLoaderPlugin(),
  16. new HtmlWebpackPlugin({
  17. hash: true,
  18. template: "dist/index.tpl.html",
  19. inject: "body",
  20. filename: "index.html"
  21. })
  22. ],
  23. module: {
  24. rules: [
  25. {
  26. test: /\.vue$/,
  27. loader: "vue-loader",
  28. exclude: /node_modules/
  29. },
  30. {
  31. test: /\.js$/,
  32. loader: "babel-loader",
  33. exclude: /node_modules/
  34. },
  35. {
  36. test: /\.scss$/,
  37. exclude: /node_modules/,
  38. use: ["vue-style-loader", "css-loader", "sass-loader"]
  39. }
  40. ]
  41. },
  42. resolve: {
  43. alias: {
  44. vue: "vue/dist/vue.js",
  45. styles: "styles"
  46. }
  47. },
  48. devServer: {
  49. static: {
  50. directory: "./dist/",
  51. watch: true
  52. },
  53. client: {
  54. webSocketURL: config.get("webSocketURL")
  55. },
  56. hot: true,
  57. historyApiFallback: true,
  58. port: config.get("frontendPort"),
  59. host: "0.0.0.0",
  60. allowedHosts: "all"
  61. }
  62. };