{"id":22161818,"url":"https://github.com/niawjunior/setup-react","last_synced_at":"2026-04-11T04:32:25.145Z","repository":{"id":71734960,"uuid":"115078959","full_name":"niawjunior/setup-react","owner":"niawjunior","description":"Setup a React Environment Using webpack and Babel Without react-create-app","archived":false,"fork":false,"pushed_at":"2017-12-22T07:42:13.000Z","size":9153,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-02T15:39:34.987Z","etag":null,"topics":["babel","react","webpack","yarn"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niawjunior.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-22T05:13:04.000Z","updated_at":"2017-12-22T05:32:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"c426d0d6-ac3d-4531-b8f7-4de888bc420a","html_url":"https://github.com/niawjunior/setup-react","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/niawjunior/setup-react","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niawjunior%2Fsetup-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niawjunior%2Fsetup-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niawjunior%2Fsetup-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niawjunior%2Fsetup-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niawjunior","download_url":"https://codeload.github.com/niawjunior/setup-react/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niawjunior%2Fsetup-react/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31669114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T17:19:37.612Z","status":"online","status_checked_at":"2026-04-11T02:00:05.776Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babel","react","webpack","yarn"],"created_at":"2024-12-02T04:16:56.079Z","updated_at":"2026-04-11T04:32:25.116Z","avatar_url":"https://github.com/niawjunior.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Setup a React Environment Using webpack and Babel\n\n### Prerequisites\n```\nyarn\n```\n\n### Installing\n\nmac os\n\n```\n\u003e brew update\n\u003e brew install yarn\n```\n\nwindows\n\n* [Download](https://yarnpkg.com/en/docs/install#windows-tab) - yarn for windows\n\n### Getting Started\n```\n\u003e mkdir hello-world-react\n\u003e cd hello-world-react\n\u003e yarn init\n```\n### Webpack installation and configuration\n```\n\u003e yarn add webpack webpack-dev-server path\n```\n\n### Create a new file, webpack.config.js\n```\n\u003e touch webpack.config.js\n```\n### Update the configuration file:\n```\n/*\n    ./webpack.config.js\n*/\nconst path = require('path');\nmodule.exports = {\n  entry: './client/index.js',\n  output: {\n    path: __dirname + \"/dist\",\n    filename: \"bundle.js\"\n  },\n  module: {\n    loaders: [\n      { test: /\\.js$/, loader: 'babel-loader', exclude: /node_modules/ },\n      { test: /\\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ }\n    ]\n  }\n}\n```\n\n### Setting up Babel\n\n```\n\u003e yarn add babel-plugin-transform-decorators-legacy babel-preset-stage-0 babel-plugin-transform-object-rest-spread babel-loader babel-core babel-preset-es2015 babel-preset-react --dev\n```\n\n### create .babelrc file\n\n```\n\u003e touch .babelrc\n```\n\n### Then we can update the file to:\n\n```\n/* \n    ./.babelrc\n*/  \n{\n    \"presets\": [\n      \"es2015\",\n      \"stage-0\",\n      \"react\"\n    ],\n    \"plugins\": [\n      \"transform-decorators-legacy\"\n    ]\n  }\n```\n\n### Setting up our React Components\n\n```\n.\n|-- node_modules\n|-- .babelrc\n|-- package.json\n|-- webpack.config.js\n|-- yarn.lock\n```\n\n### Create a new folder client and add an index.js file and an index.html file.\n\n```\n\u003e mkdir client\n\u003e cd client\n\u003e touch index.js\n\u003e touch index.html\n\u003e cd .. \n```\n\n### Now we have this:\n```\n.\n|-- client\n     |-- index.html\n     |-- index.js\n|-- .babelrc\n|-- package.json\n|-- webpack.config.js\n|-- yarn.lock\n```\n\n### Open up index.js and add:\n```\nconsole.log('hello react')\n```\n\n### Update index.html to:\n```\n/*\n    ./client/index.html\n    basic html skeleton\n*/\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003ctitle\u003eReact App Setup\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv id=\"root\"\u003e\n\n    \u003c/div\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n### Html-Webpack-Plugin\nSimplifies creation of HTML files to serve your webpack bundles\n```\n\u003e yarn add html-webpack-plugin\n```\nThen open up your webpack.config.js and add a few configurations.\n```\n/* \n    ./webpack.config.js\n*/\nconst path = require('path');\n\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\nconst HtmlWebpackPluginConfig = new HtmlWebpackPlugin({\n  template: './client/index.html',\n  filename: 'index.html',\n  inject: 'body'\n})\n\nmodule.exports = {\n\n...\n\nmodule: {\n    loaders: [\n        ...\n    ]\n},\n// add this line\nplugins: [HtmlWebpackPluginConfig]\n}\n```\n### Run it!\n Open up your package.json and let's add a start script.\n ```\n /*\n    ./package.json\n*/\n{\n  \"name\": \"hello-world-react\",\n  \"version\": \"1.0.0\",\n  \"main\": \"index.js\",\n  \"license\": \"MIT\",\n\n  // add the scripts key to your package.json\n\n  \"scripts\": {\n    \"start\": \"webpack-dev-server\"\n  },\n\n  \"dependencies\": {\n  ...\n  },\n  \"devDependencies\": {\n  ...\n  }\n}\n ```\n \n Now we can go to our terminal and run:\n ```\n \u003e yarn start\n ```\n Open your browser on http://localhost:8080/\n  If you check your console you'll see our message \"hello react\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniawjunior%2Fsetup-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniawjunior%2Fsetup-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniawjunior%2Fsetup-react/lists"}