webpack.config.js 745 B

12345678910111213141516171819202122232425262728
  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. }
  27. };