Advertisement
fakesamgregory

Master React in Webflow - VSCode Setup

Nov 6th, 2024 (edited)
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* --------------
  2.     * -- Expected file system -- *
  3.     - package.json
  4.     - package-lock.json (generated by npm)
  5.     - src/
  6.         - page.js
  7.     - .babelrc
  8.     - webpack.config.js
  9.     - dist/ (this and contents generated by webpack)
  10.         - page.js
  11.    
  12.     * -- npm scripts -- *
  13.     npm init
  14.     npm i react react-dom
  15.     npm i @babel/preset-env @babel/preset-react babel-loader -D
  16.  
  17. /* ----------- */
  18. // package.json
  19. ...
  20. "scripts": {
  21.     "start": "webpack",
  22.     "dev": "webpack --watch --progress",
  23. },     
  24. ...
  25.  
  26. /* ----------- */
  27. // webpack.config.js
  28. const path = require("path");
  29.  
  30. module.exports = {
  31.   entry: {
  32.     ["page"]: "./src/page.js",
  33.   },
  34.   module: {
  35.     rules: [
  36.       {
  37.         test: /\.(js|jsx)$/,
  38.         exclude: /node_modules/,
  39.         use: ["babel-loader"],
  40.       },
  41.     ],
  42.   },
  43.   resolve: {
  44.     extensions: ["*", ".js", ".jsx"],
  45.   },
  46.   mode: "production",
  47.   output: {
  48.     path: path.resolve(__dirname, "dist"),
  49.     filename: "[name].js",
  50.     library: "[name]",
  51.     libraryTarget: "umd",
  52.     globalObject: "this",
  53.     umdNamedDefine: true,
  54.     clean: true,
  55.   },
  56. };
  57. /* ----------- */
  58.  
  59. // .babelrc
  60. {
  61.   "presets": ["@babel/preset-env", "@babel/preset-react"]
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement