This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// webpack-dev-server.js | |
// dev-server is responsible for running your project locally | |
const WebpackDevServer = require("webpack-dev-server"); | |
const webpack = require("webpack"); | |
const paths = require("./paths"); | |
const config = require("./webpack-dev-config.js"); | |
// Change port to suit your preference |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// paths.js | |
// Paths will export some path variables that we'll | |
// use in other Webpack config and server files | |
const path = require("path"); | |
const fs = require("fs"); | |
const appDirectory = fs.realpathSync(process.cwd()); | |
const resolveApp = relativePath => path.resolve(appDirectory, relativePath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// webpack-common-config.js | |
// This file will contain configuration data that | |
// is shared between development and production builds. | |
const HtmlWebpackPlugin = require("html-webpack-plugin"); | |
const path = require("path"); | |
const paths = require("./paths"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// webpack-dev-config.js | |
// configuration data related to development only | |
const path = require("path"); | |
const webpack = require("webpack"); | |
const { merge } = require("webpack-merge"); | |
const paths = require("./paths"); | |
// import common webpack config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// webpack-prod-config.js | |
// contains configuration data related to prod build | |
const path = require("path"); | |
const webpack = require("webpack"); | |
const merge = require("webpack-merge"); | |
const UglifyJSPlugin = require("uglifyjs-webpack-plugin"); | |
const ExtractTextPlugin = require("extract-text-webpack-plugin"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "react-starter", | |
"version": "1.0.0", | |
"description": "A React starter project", | |
"main": "index.jsx", | |
"author": "Joshua Crass <joshua.crass@gmail.com>", | |
"license": "UNLICENSED", | |
"private": true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width" /> | |
<title>React Starter</title> | |
<script src="./index.jsx"></script> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import App from "./app"; | |
ReactDOM.render(<App />, document.getElementById("root")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { hot } from "react-hot-loader"; | |
import style from "./app.css"; | |
const App = () => { | |
return <div className={style.app}>react Starter 🚀 </div>; | |
}; | |
export default hot(module)(App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"scripts": { | |
"build": "yarn clean; webpack --config config/webpack-prod-config.js", | |
"clean": "rm -rf build/*", | |
"start:dev": "node config/webpack-dev-server.js", | |
"start:prod": "yarn build; serve build" | |
}, |