Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save snassr/3053a4abce90975b4b87bbac089761ae to your computer and use it in GitHub Desktop.
Save snassr/3053a4abce90975b4b87bbac089761ae to your computer and use it in GitHub Desktop.
Medium Blog - WebSockets React & Go - Setup Node/React.js Environment
# make frontend directory and change to that directory
mkdir -p ~/blog-goreactsockets/frontend && cd ~/blog-goreactsockets/frontend
# create webpack configuration file
echo "module.exports = {
entry: [
'./src/index.js'
],
module: {
loaders: [
{
test: /\.js|.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react', 'stage-2']
}
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx']
},
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: 'bundle.js'
},
devServer: {
contentBase: './dist'
}
};" > webpack.config.js
# create node package.json package management/configuration file
echo '{
"name": "frontend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --progress --colors --config ./webpack.config.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"events": "^1.1.1",
"react": "^16.2.0",
"react-dom": "^16.2.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.11.1"
}
}' > package.json
# configure babel to handle esX (es5, es6...)
echo '{ "presets": ["react", "es2015"] }' > .babelrc
# install node project dependencies
npm install .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment