Skip to content

Commit

Permalink
a nice setup creds to alex chen
Browse files Browse the repository at this point in the history
  • Loading branch information
shannenwu committed Jan 3, 2019
1 parent e3fd5e7 commit c1a2562
Show file tree
Hide file tree
Showing 9 changed files with 2,779 additions and 291 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
}],
"react",
"stage-0"
]
],
"plugins": ["react-hot-loader/babel"]
}
1 change: 0 additions & 1 deletion README.md

This file was deleted.

2,933 changes: 2,688 additions & 245 deletions package-lock.json
100644 → 100755

Large diffs are not rendered by default.

21 changes: 14 additions & 7 deletions package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "babel-node src/server/app.js",
"prestart": "babel src/client/app.js -o public/bundle.js"
"start": "webpack-dev-server --config ./webpack.config.js --mode development --port 3000"
},
"repository": {
"type": "git",
Expand All @@ -19,21 +18,29 @@
},
"homepage": "https://github.com/shannenwu/catbook-react#readme",
"dependencies": {
"@babel/preset-react": "^7.0.0",
"express": "^4.16.4",
"webpack": "^4.28.3",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.14"
"react": "^16.7.0",
"react-dom": "^16.7.0"
},
"devDependencies": {
"@babel/preset-react": "^7.0.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"css-loader": "^2.1.0",
"html-webpack-plugin": "^3.2.0",
"node-sass": "^4.11.0",
"react": "^16.7.0",
"react-dom": "^16.7.0"
"react-dom": "^16.7.0",
"react-hot-loader": "^4.6.3",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"webpack": "^4.28.3",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.14"
}
}
11 changes: 0 additions & 11 deletions public/index.html

This file was deleted.

13 changes: 8 additions & 5 deletions src/client/app.js → src/client/index.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import React from 'react';
import ReactDOM from 'react-dom';

class App extends React.Component {

render() {
return (
<h1>Hello from React!</h1>
);
return (
<h1>let's get this BREAD!</h1>
);
}
}
ReactDOM.render(
<App/>,
document.getElementById('root')
);
);

module.hot.accept();
11 changes: 11 additions & 0 deletions src/client/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Catbook</title>
</head>
<body>
<div id="root"></div>
<script src="bundle.js"></script>
</body>
</html>
13 changes: 8 additions & 5 deletions src/server/app.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import express from 'express';
import path from 'path';
const express = require('express');
const path = erquire('path);')

const app = express();
const publicPath = path.resolve(__dirname, '..', '..', 'public');
const publicPath = path.resolve(__dirname, '..', '..', 'dist');

app.use(express.static(publicPath));
app.listen(3000, () => {
console.log(`MERN Boilerplate listening on port 3000 and looking in folder ${publicPath}`);

app.listen(3000, () => {
console.log(`Listening on port 3000 and looking in folder ${publicPath}`);
});
64 changes: 48 additions & 16 deletions webpack.config.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,19 +1,51 @@
const path = require('path');
const entryFile = path.resolve(__dirname, 'src', 'client', 'app.js');
const outputDir = path.resolve(__dirname, 'public');
const entryFile = path.resolve(__dirname, 'src', 'client', 'index.js');
const outputDir = path.resolve(__dirname, 'dist');

const HtmlWebPackPlugin = require("html-webpack-plugin");
const webpack = require('webpack');

const htmlPlugin = new HtmlWebPackPlugin({
template: "./src/client/public/index.html",
filename: "index.html"
});

module.exports = {
entry: ['babel-polyfill', entryFile],
output: {
filename: 'bundle.js',
path: outputDir
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /node_modules/
}
]
}
entry: ['babel-polyfill', entryFile],
output: {
filename: 'bundle.js',
path: outputDir
},
module: {
rules: [

{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(scss|css)$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
},
{
loader: 'sass-loader'
}
]
}
]
},
plugins: [
htmlPlugin,
new webpack.HotModuleReplacementPlugin()
],
devServer: {
contentBase: './dist',
hot: true
}
};

0 comments on commit c1a2562

Please sign in to comment.