webpack.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. process.env.NODE_CONFIG_DIR = `${__dirname}/dist/config/`;
  2. const config = require("config");
  3. const VueLoaderPlugin = require("vue-loader/lib/plugin");
  4. const WebpackMd5Hash = require("webpack-md5-hash");
  5. const HtmlWebpackPlugin = require("html-webpack-plugin");
  6. module.exports = {
  7. entry: "./main.js",
  8. mode: "development",
  9. devtool: "inline-source-map",
  10. output: {
  11. path: `${__dirname}/dist/build/`,
  12. filename: "[name].[hash].js",
  13. publicPath: "/"
  14. },
  15. plugins: [
  16. new VueLoaderPlugin(),
  17. new WebpackMd5Hash(),
  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. test: /\.vue$/,
  29. loader: "vue-loader",
  30. exclude: /node_modules/
  31. },
  32. {
  33. test: /\.js$/,
  34. loader: "babel-loader",
  35. exclude: /node_modules/
  36. },
  37. {
  38. test: /\.scss$/,
  39. exclude: /node_modules/,
  40. use: ["vue-style-loader", "css-loader", "sass-loader"]
  41. }
  42. ]
  43. },
  44. resolve: {
  45. alias: {
  46. vue: "vue/dist/vue.js",
  47. styles: "styles"
  48. }
  49. },
  50. devServer: {
  51. contentBase: "./dist/",
  52. historyApiFallback: true,
  53. hot: true,
  54. port: config.get("frontendPort"),
  55. public: config.get("frontendDomain"),
  56. watchOptions: {
  57. aggregateTimeout: 300,
  58. poll: 1000
  59. },
  60. host: "0.0.0.0",
  61. disableHostCheck: true
  62. }
  63. };