commit 5e2a57d9eb8298a7ce92788571ed4f8731dc124f Author: catarak Date: Tue May 3 00:09:16 2016 -0400 initial commit diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..9f73d79c --- /dev/null +++ b/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": ["react", "es2015"], + "env": { + "production": { + "plugins": [ + "transform-react-remove-prop-types", + "transform-react-constant-elements", + "transform-react-inline-elements" + ] + } + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..87f88f4b --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +node_modules/ +npm-debug.log +dump.rdb +public/* +static/dist +static/css/app.min.css diff --git a/README.md b/README.md new file mode 100644 index 00000000..99a54a8e --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +MERN Stack - MongoDB, Express, React/Redux, Node +https://github.com/Hashnode/mern-starter diff --git a/client/index.js b/client/index.js new file mode 100644 index 00000000..25140a92 --- /dev/null +++ b/client/index.js @@ -0,0 +1,7 @@ +import React from 'react'; +import { render } from 'react-dom'; + +render( +

Hello world!

, + document.getElementById('root') +) \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 00000000..7548e2ef --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + p5.js Web Editor + + +
+
+ + + \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 00000000..9ee452d7 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +require('babel-register'); +require('babel-polyfill'); +require('./server/server'); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 00000000..678edd59 --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/server/config.js b/server/config.js new file mode 100644 index 00000000..7f40eb8e --- /dev/null +++ b/server/config.js @@ -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; \ No newline at end of file diff --git a/server/server.js b/server/server.js new file mode 100644 index 00000000..c854da86 --- /dev/null +++ b/server/server.js @@ -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; \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 00000000..02e7f2fd --- /dev/null +++ b/webpack.config.js @@ -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'], + }, + }, + ], + }, +}; \ No newline at end of file