Skip to content

Instantly share code, notes, and snippets.

@jylock
Last active November 15, 2017 11:05
Show Gist options
  • Select an option

  • Save jylock/69a9fbcdc41f08c5d4291db3f95b4003 to your computer and use it in GitHub Desktop.

Select an option

Save jylock/69a9fbcdc41f08c5d4291db3f95b4003 to your computer and use it in GitHub Desktop.
Starting new React project
link to codeacademy tutorial
https://www.codecademy.com/articles/react-setup-v
npm init
npm install --save react
npm install --save react-dom (npm i -S {react,react-dom})
npm install --save-dev babel-core babel-loader babel-preset-env babel-preset-react (npm i -D babel-{core,loader} babel-preset-env babel-preset-react)
In root dir, create a file '.babelrc'
{"presets": ["env", "react"]}
Set up webpack (transformation manager)
npm install --save-dev webpack webpack-dev-server html-webpack-plugin (npm i -D webpack webpack-dev-server html-webpack-plugin)
create webpack config file 'webpack.config.js':
var HTMLWebpackPlugin = require('html-webpack-plugin');
var HTMLWebpackPluginConfig = new HTMLWebpackPlugin({
template: __dirname + '/app/index.html',
filename: 'index.html',
inject: 'head'
});
module.exports = {
entry: __dirname + '/app/index.js',
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
},
output: {
filename: 'transformed.js',
path: __dirname + '/build'
},
plugins: [HTMLWebpackPluginConfig]
};
npm run build
npm run start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment