webpack.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. const VueLoaderPlugin = require("vue-loader/lib/plugin");
  2. const WebpackMd5Hash = require("webpack-md5-hash");
  3. const HtmlWebpackPlugin = require("html-webpack-plugin");
  4. module.exports = {
  5. entry: "./main.js",
  6. mode: "development",
  7. devtool: "inline-source-map",
  8. output: {
  9. path: `${__dirname}/dist/build/`,
  10. filename: "[name].[hash].js",
  11. publicPath: "/"
  12. },
  13. plugins: [
  14. new VueLoaderPlugin(),
  15. new WebpackMd5Hash(),
  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. contentBase: "./dist/",
  50. historyApiFallback: true,
  51. hot: true,
  52. port: 80,
  53. public: "http://localhost",
  54. watchOptions: {
  55. aggregateTimeout: 300,
  56. poll: 1000
  57. },
  58. host: "0.0.0.0",
  59. disableHostCheck: true
  60. }
  61. };