initial commit
This commit is contained in:
commit
5e2a57d9eb
10 changed files with 145 additions and 0 deletions
12
.babelrc
Normal file
12
.babelrc
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"presets": ["react", "es2015"],
|
||||||
|
"env": {
|
||||||
|
"production": {
|
||||||
|
"plugins": [
|
||||||
|
"transform-react-remove-prop-types",
|
||||||
|
"transform-react-constant-elements",
|
||||||
|
"transform-react-inline-elements"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
.DS_Store
|
||||||
|
node_modules/
|
||||||
|
npm-debug.log
|
||||||
|
dump.rdb
|
||||||
|
public/*
|
||||||
|
static/dist
|
||||||
|
static/css/app.min.css
|
2
README.md
Normal file
2
README.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
MERN Stack - MongoDB, Express, React/Redux, Node
|
||||||
|
https://github.com/Hashnode/mern-starter
|
7
client/index.js
Normal file
7
client/index.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { render } from 'react-dom';
|
||||||
|
|
||||||
|
render(
|
||||||
|
<h1>Hello world!</h1>,
|
||||||
|
document.getElementById('root')
|
||||||
|
)
|
11
index.html
Normal file
11
index.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>p5.js Web Editor</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root">
|
||||||
|
</div>
|
||||||
|
<script src="/dist/bundle.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
3
index.js
Normal file
3
index.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
require('babel-register');
|
||||||
|
require('babel-polyfill');
|
||||||
|
require('./server/server');
|
33
package.json
Normal file
33
package.json
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
"name": "p5.js-web-editor",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "The web editor for p5.js.",
|
||||||
|
"main": "server.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "Cassie Tarakajian",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"babel-loader": "^6.2.4",
|
||||||
|
"babel-plugin-transform-react-constant-elements": "^6.8.0",
|
||||||
|
"babel-plugin-transform-react-inline-elements": "^6.8.0",
|
||||||
|
"babel-plugin-transform-react-remove-prop-types": "^0.2.6",
|
||||||
|
"babel-polyfill": "^6.8.0",
|
||||||
|
"babel-preset-es2015": "^6.6.0",
|
||||||
|
"babel-preset-react": "^6.5.0",
|
||||||
|
"babel-preset-react-hmre": "^1.1.1",
|
||||||
|
"babel-register": "^6.8.0",
|
||||||
|
"webpack": "^1.13.0",
|
||||||
|
"webpack-dev-middleware": "^1.6.1",
|
||||||
|
"webpack-hot-middleware": "^2.10.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"babel-core": "^6.8.0",
|
||||||
|
"react": "^15.0.2",
|
||||||
|
"react-dom": "^15.0.2"
|
||||||
|
}
|
||||||
|
}
|
6
server/config.js
Normal file
6
server/config.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
const config = {
|
||||||
|
mongoURL: process.env.MONGO_URL || 'mongodb://localhost:27017/p5js-web-editor',
|
||||||
|
port: process.env.PORT || 8000,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
33
server/server.js
Normal file
33
server/server.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import Express from 'express';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
//Webpack Requirements
|
||||||
|
import webpack from 'webpack';
|
||||||
|
import config from '../webpack.config';
|
||||||
|
import webpackDevMiddleware from 'webpack-dev-middleware';
|
||||||
|
import webpackHotMiddleware from 'webpack-hot-middleware';
|
||||||
|
|
||||||
|
const app = new Express();
|
||||||
|
|
||||||
|
//add check if production environment here
|
||||||
|
const compiler = webpack(config);
|
||||||
|
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath }));
|
||||||
|
app.use(webpackHotMiddleware(compiler));
|
||||||
|
|
||||||
|
//Import all required modules
|
||||||
|
import serverConfig from './config';
|
||||||
|
|
||||||
|
app.use(Express.static(path.resolve(__dirname, '../static')));
|
||||||
|
|
||||||
|
app.get("/", function(req, res) {
|
||||||
|
res.sendFile(path.resolve(__dirname + '/../index.html'));
|
||||||
|
})
|
||||||
|
|
||||||
|
// start app
|
||||||
|
app.listen(serverConfig.port, (error) => {
|
||||||
|
if (!error) {
|
||||||
|
console.log(`p5js web editor is running on port: ${serverConfig.port}!`); // eslint-disable-line
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default app;
|
31
webpack.config.js
Normal file
31
webpack.config.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
var webpack = require('webpack');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
devtool: 'cheap-module-eval-source-map',
|
||||||
|
entry: ['webpack-hot-middleware/client',
|
||||||
|
'./client/index.js',
|
||||||
|
],
|
||||||
|
output: {
|
||||||
|
path: __dirname + '/dist/',
|
||||||
|
filename: 'bundle.js',
|
||||||
|
publicPath: '/dist/'
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['', '.js', '.jsx'],
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.HotModuleReplacementPlugin()
|
||||||
|
],
|
||||||
|
module: {
|
||||||
|
loaders: [
|
||||||
|
{
|
||||||
|
test: /\.jsx*$/,
|
||||||
|
exclude: [/node_modules/, /.+\.config.js/],
|
||||||
|
loader: 'babel',
|
||||||
|
query: {
|
||||||
|
presets: ['react-hmre'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
Loading…
Reference in a new issue