webpack.config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const path = require("path"); // NodeJS builtin.
  2. module.exports = {
  3. entry: "./src/index.js",
  4. output: {
  5. filename: "bundle.js",
  6. path: path.join(__dirname, "build") // path must be absolute.
  7. },
  8. module: {
  9. rules: [
  10. {
  11. // When a file name matches this expression...
  12. test: /\.js$/,
  13. // ...use that loader on it.
  14. use: "babel-loader"
  15. },
  16. {
  17. test: /\.scss$/,
  18. use: [
  19. // Apply down to top (right to left), like wrapped function calls.
  20. "style-loader", // Apply third: insert script tag for browser use.
  21. "css-loader", // Apply second: convert CSS to JS.
  22. "sass-loader" // Apply first: compile SASS to CSS.
  23. ]
  24. },
  25. {
  26. // Even for files requested by the CSS loader, which marks them as dependencies.
  27. test: /\.jpe?g$/,
  28. use: [
  29. // Use object format instead of string to pass options to a loader.
  30. {
  31. loader: "url-loader",
  32. options: {
  33. limit: 10000
  34. }
  35. }
  36. ]
  37. }
  38. ]
  39. }
  40. };