Skip to content

Commit

Permalink
React, Babel and Webpack into a dist folder installed and tested
Browse files Browse the repository at this point in the history
  • Loading branch information
Benny committed Aug 27, 2017
1 parent 52acc5d commit 3906aec
Show file tree
Hide file tree
Showing 7 changed files with 2,444 additions and 34 deletions.
62 changes: 31 additions & 31 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"root": true,
"extends": "airbnb-base",
"env": {
"node": true,
"es6": true,
"mocha": true
},
"rules": {
"one-var": 0,
"one-var-declaration-per-line": 0,
"new-cap": 0,
"consistent-return": 0,
"no-param-reassign": 0,
"comma-dangle": 0,
"curly": ["error", "multi-line"],
"import/no-unresolved": [2, { "commonjs": true }],
"no-shadow": ["error", { "allow": ["req", "res", "err"] }],
"valid-jsdoc": ["error", {
"requireReturn": true,
"requireReturnType": true,
"requireParamDescription": false,
"requireReturnDescription": true
}],
"require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true
}
}]
}
"root": true,
"extends": "airbnb-base",
"env": {
"node": true,
"es6": true,
"mocha": true
},
"rules": {
"one-var": 0,
"one-var-declaration-per-line": 0,
"new-cap": 0,
"consistent-return": 0,
"no-param-reassign": 0,
"comma-dangle": 0,
"curly": ["error", "multi-line"],
"import/no-unresolved": [2, { "commonjs": true }],
"no-shadow": ["error", { "allow": ["req", "res", "err"] }],
"valid-jsdoc": ["error", {
"requireReturn": true,
"requireReturnType": true,
"requireParamDescription": false,
"requireReturnDescription": true
}],
"require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true
}
}]
}
}
2,274 changes: 2,274 additions & 0 deletions client/dist/app/bundle.js

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions client/dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<title>Webpack App</title>
</head>

<body>
<div id="app"></div>
<script src="/app/bundle.js"></script>
</body>


</html>
15 changes: 15 additions & 0 deletions client/src/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { render } from 'react-dom';


class App extends React.Component {
render() {
return (
<div className='jumbotron'>
<h1 class="display-3">Hello, world!</h1>
</div>
)
}
}

render(<App/>,window.document.getElementById('app'))
18 changes: 18 additions & 0 deletions client/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<title>Webpack App</title>
</head>

<body>
<div id="app"></div>
<script src="/app/bundle.js"></script>
</body>


</html>
20 changes: 17 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"start": "node server/dist/bin/www.js",
"test:db": "sequelize db:migrate",
"start:dev": "nodemon server/dist/bin/www.js",
"start:webdev": "npm run build:webdev",
"build:webdev": "webpack -d && cp client/src/index.html client/dist/index.html && webpack-dev-server --content-base client/src/ --inline --hot",
"build:prod webdev": "webpack -p && cp client/src/index.html client/dist/index.html",
"build": "babel server/src --watch --out-dir server/dist --presets es2015",
"test": "cross-env NODE_ENV=test& mocha server/dist/test/*.js --timeout 10000 ",
"coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text --reporter=lcovonly mocha --compilers js:babel-register server/src/test/*.js"
Expand All @@ -20,7 +23,7 @@
"license": "ISC",
"dependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-core": "^6.26.0",
"babel-eslint": "^7.2.3",
"bcrypt": "^1.0.2",
"bcrypt-nodejs": "0.0.3",
Expand All @@ -42,13 +45,23 @@
"nodemon": "^1.11.0",
"pg": "^7.0.2",
"pg-hstore": "^2.3.2",
"react": "^15.6.1",
"react-cookie": "^2.0.8",
"react-dom": "^15.6.1",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
"redux": "^3.7.2",
"redux-form": "^6.0.0-rc.3",
"redux-thunk": "^2.2.0",
"sequelize": "^4.7.5",
"sequelize-cli": "^2.8.0",
"swagger-jsdoc": "^1.3.0",
"to-title-case": "^1.0.0",
"unique-random": "^1.0.0"
"unique-random": "^1.0.0",
"webpack": "^3.5.5"
},
"devDependencies": {
"babel-loader": "^7.1.2",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.6.0",
"babel-preset-es2015": "^6.24.1",
Expand All @@ -57,11 +70,12 @@
"babel-register": "^6.24.1",
"coveralls": "^2.13.1",
"cross-env": "^5.0.5",
"html-webpack-plugin": "^2.30.1",
"mocha-lcov-reporter": "^1.3.0",
"nyc": "^11.1.0",
"path": "^0.12.7",
"sentence-case": "^2.1.1",
"validator": "^8.0.0",
"validators": "^0.3.1"
}
}
}
71 changes: 71 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const webpack = require('webpack');
const path = require('path');
//const ExtractTextPlugin = require('extract-text-webpack-plugin');


const DIST_DIR = path.resolve(__dirname, "./client/dist");
const SRC_DIR = path.resolve(__dirname, "./client/src");

const config = {
entry: SRC_DIR + "/app/index.js",
output: {
path: DIST_DIR + "/app",
filename: "bundle.js",
publicPath: "/app/"
},
module: {
loaders: [{
test: /\.js?/,
include: SRC_DIR,
loader: "babel-loader",
query: {
presets: ["react", "es2015", "stage-2"]
}
}]
}
};

module.exports = config;

// const config = {
// context: __dirname,
// entry: './src/index.js',
// output: {
// path: __dirname,
// filename: 'bundle.js'
// },
// module: {
// loaders: [{
// exclude: /node_modules/,
// test: /\.(js|jsx)$/,
// loader: 'babel'
// },
// {
// test: /\.scss$/,
// loader: ExtractTextPlugin.extract('css!sass')
// }
// ]
// },
// devServer: {
// historyApiFallback: true,
// contentBase: './'
// },
// plugins: [
// new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify('production') } }),
// new webpack.optimize.DedupePlugin(),
// new webpack.optimize.OccurenceOrderPlugin(),
// new webpack.optimize.UglifyJsPlugin({
// compress: { warnings: false },
// output: { comments: false },
// mangle: false,
// sourcemap: false,
// minimize: true,
// mangle: { except: ['$super', '$', 'exports', 'require', '$q', '$ocLazyLoad'] }
// }),
// new ExtractTextPlugin('src/public/stylesheets/app.css', {
// allChunks: true
// })
// ]
// };

// module.exports = config;

0 comments on commit 3906aec

Please sign in to comment.