Plan stuff. Log stuff.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.2 KiB

4 years ago
  1. const MiniCssExtractPlugin = require("mini-css-extract-plugin");
  2. const path = require("path");
  3. const mode = process.env.NODE_ENV || "development";
  4. const prod = mode === "production";
  5. module.exports = {
  6. entry: {
  7. bundle: ["./src/main.js"]
  8. },
  9. resolve: {
  10. alias: {
  11. svelte: path.resolve("node_modules", "svelte")
  12. },
  13. extensions: [".mjs", ".js", ".svelte"],
  14. mainFields: ["svelte", "browser", "module", "main"]
  15. },
  16. output: {
  17. path: __dirname + "/public",
  18. filename: "[name].js",
  19. chunkFilename: "[name].[id].js"
  20. },
  21. module: {
  22. rules: [
  23. {
  24. test: /\.svelte$/,
  25. use: {
  26. loader: "svelte-loader",
  27. options: {
  28. emitCss: true,
  29. hotReload: true
  30. }
  31. }
  32. },
  33. {
  34. test: /\.css$/,
  35. use: [
  36. /**
  37. * MiniCssExtractPlugin doesn"t support HMR.
  38. * For developing, use "style-loader" instead.
  39. * */
  40. prod ? MiniCssExtractPlugin.loader : "style-loader",
  41. "css-loader"
  42. ]
  43. }
  44. ]
  45. },
  46. mode,
  47. plugins: [
  48. new MiniCssExtractPlugin({
  49. filename: "[name].css"
  50. }),
  51. ],
  52. devtool: prod ? false: "source-map",
  53. devServer: {
  54. historyApiFallback: true,
  55. proxy: {
  56. "/api": {
  57. "changeOrigin": true,
  58. "cookieDomainRewrite": "localhost",
  59. "target": "http://localhost:8001",
  60. },
  61. },
  62. },
  63. };