Skip to content

Update 2021 #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 96 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
17f978e
Update to Webpack 2. Update dependencies.
coryhouse Feb 20, 2017
9837ba5
Fix syntax errors
coryhouse Apr 19, 2017
b851de8
Merge branch 'master' into update-dependencies
coryhouse Jun 3, 2017
2540ce9
Upgrade dependencies
coryhouse Jun 3, 2017
d3a6aee
Upgrade packages
coryhouse Jun 3, 2017
5b8a253
Switch to babel-preset-env which replaced babel-preset-latest
Oct 11, 2017
f57e2d7
Remove needless escape characters
Oct 11, 2017
27341a5
Update dependencies
Oct 11, 2017
890b415
Update webpack.config to modern syntax
Oct 31, 2017
30a70fb
Update dependencies including Webpack 4
coryhouse May 8, 2018
bebdb27
Update webpack.config.prod.js
coryhouse May 8, 2018
751c4b7
Remove nsp since npm has security checks built in now
coryhouse Jul 8, 2018
fa4732b
Merge branch 'update-dependencies' of https://github.com/coryhouse/ja…
coryhouse Jul 8, 2018
838e8b4
Update dependencies
coryhouse Oct 31, 2018
946d4eb
Upgrade Babel and ESLint
coryhouse Oct 31, 2018
90f42b2
Merge branch 'master' into update-dependencies
coryhouse Nov 2, 2018
9f84e57
Update deps
coryhouse Nov 21, 2018
ae1c8ec
Merge branch 'update-dependencies' of https://github.com/coryhouse/ja…
coryhouse Nov 21, 2018
c9dfefb
Comment tweak
coryhouse Nov 21, 2018
56bd631
Upgrade jsdom
coryhouse Dec 7, 2018
f41c337
Upgrade dependencies
coryhouse May 23, 2019
2870816
Update URL
coryhouse Jun 16, 2019
b3611ce
Eliminate separate config
coryhouse Jun 16, 2019
6a89395
Eliminate separate config
coryhouse Jun 16, 2019
790acac
Switching to prettier
coryhouse Jun 16, 2019
8503916
Change node version
coryhouse Jun 16, 2019
fd582df
Update min Node version
coryhouse Jun 16, 2019
ee5c0ab
Upgrade deps and add babel and eslint configs
coryhouse Jun 16, 2019
a974a53
Fix compression call order
coryhouse Jun 16, 2019
2355faa
Tweak comment
coryhouse Jun 16, 2019
c6dad1a
Tweak comment
coryhouse Jun 16, 2019
a81d95d
prettier
coryhouse Jun 17, 2019
e36e0d2
prettier
coryhouse Jun 17, 2019
19dfc78
prettier
coryhouse Jun 17, 2019
e64b3ec
Update to latest versions
coryhouse Aug 29, 2020
e22e9ae
Upgrade versions
coryhouse Aug 29, 2020
a20911c
Extract config
coryhouse Aug 29, 2020
e9d14ee
Add config back
coryhouse Aug 29, 2020
ff2c1a2
Revert quotes
coryhouse Aug 29, 2020
673dece
revert order
coryhouse Aug 29, 2020
e667589
update deps
coryhouse Aug 29, 2020
66318fe
reorder
coryhouse Aug 29, 2020
a07b8c4
revert quotes
coryhouse Aug 29, 2020
f32d618
revert
coryhouse Aug 29, 2020
45b734f
revert
coryhouse Aug 29, 2020
aa62025
revert
coryhouse Aug 29, 2020
a2edf0e
revert quotes
coryhouse Aug 29, 2020
5dae3bb
Remove
coryhouse Aug 29, 2020
3939517
Make consistent loaders
coryhouse Aug 29, 2020
f462c60
Simplify entry
coryhouse Aug 29, 2020
2e60f8e
remove jsx
coryhouse Aug 29, 2020
b694377
Remove unused
coryhouse Aug 29, 2020
07c5e3a
doc packages
coryhouse Aug 29, 2020
d14897d
revert
coryhouse Aug 29, 2020
d1ada0d
revert
coryhouse Aug 29, 2020
88aa91f
Remove hot
coryhouse Aug 29, 2020
749f3fd
Remove localtunnel
coryhouse Aug 29, 2020
abf9358
revert
coryhouse Aug 29, 2020
9c40f8c
revert
coryhouse Aug 29, 2020
633f957
revert
coryhouse Aug 29, 2020
f0eb168
revert
coryhouse Aug 29, 2020
b2d7d10
revert
coryhouse Aug 29, 2020
ed1c2f2
Remove unused
coryhouse Aug 29, 2020
e77be33
remove escapes
coryhouse Aug 29, 2020
ebbe2db
Remove needless setting
coryhouse Aug 30, 2020
977ecd2
remove needless plugin
coryhouse Aug 30, 2020
86f354b
Remove target
coryhouse Aug 30, 2020
90673d6
Hash css
coryhouse Aug 30, 2020
0f139c2
remove default
coryhouse Aug 30, 2020
c7c5bd9
Fix source map setting
coryhouse Aug 30, 2020
17d23d8
Fix comment
coryhouse Aug 30, 2020
b60d2b7
use default
coryhouse Aug 30, 2020
b8a760f
Use default
coryhouse Aug 30, 2020
dc4f07c
comment
coryhouse Aug 30, 2020
a3867cf
remove
coryhouse Aug 30, 2020
fb50732
Upgrade deps
coryhouse Feb 10, 2021
91c4920
remove noinfo
coryhouse Feb 10, 2021
8378c86
add lt script
coryhouse Feb 10, 2021
52f770e
upgrade cheerio
coryhouse Feb 10, 2021
d98a181
update lock
coryhouse Feb 12, 2021
e51bfe5
Change order
coryhouse Feb 27, 2021
38c13fc
Upgrade versions
coryhouse Feb 27, 2021
71f0ac5
Tweak id gen
coryhouse Feb 28, 2021
5731d47
Update deps
coryhouse Feb 28, 2021
c77605e
Reformat and fix hash
coryhouse Mar 6, 2021
40295d2
Tweak comment
coryhouse Mar 6, 2021
a88086d
Reorder
coryhouse Mar 13, 2021
64ae2d4
Add semi
coryhouse Mar 13, 2021
f2d5571
Remove line
coryhouse Mar 13, 2021
6cbdd08
add semi
coryhouse Mar 13, 2021
51959a2
Prettier
coryhouse Mar 13, 2021
5bd2bc0
tweak comment
coryhouse Mar 13, 2021
5e6d12f
leave in
coryhouse Mar 13, 2021
68a5676
add space
coryhouse Mar 13, 2021
f905d41
remove blank
coryhouse Mar 13, 2021
8abe85d
Update imports
coryhouse Jun 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"presets": [
"latest"
]
"presets": ["@babel/preset-env"],
"env": {
"production": {
"presets": [
[
"@babel/preset-env",
{
"targets": "> 0.25%, not dead"
}
]
]
}
}
}
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: node_js
node_js:
- "6"
- "14"
72 changes: 37 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This is a generic JavaScript development environment that I build from scratch i

## Get Started

1. **Install [Node 6 or newer](https://nodejs.org)**. Need to run multiple versions of Node? Use [nvm](https://github.com/creationix/nvm) or [nvm-windows](https://github.com/coreybutler/nvm-windows)
1. **Install [Node 12 or newer](https://nodejs.org)**. Need to run multiple versions of Node? Use [nvm](https://github.com/creationix/nvm) or [nvm-windows](https://github.com/coreybutler/nvm-windows)
2. **Clone this repository.** - `git clone https://github.com/coryhouse/javascript-development-environment.git` or [download the zip](https://github.com/coryhouse/javascript-development-environment/archive/master.zip)
3. **Make sure you're in the directory you just created.** - `cd javascript-development-environment`
4. **Install Node Packages.** - `npm install`
Expand All @@ -24,37 +24,39 @@ This is a generic JavaScript development environment that I build from scratch i

### Development Dependencies

| **Dependency** | **Use** |
| --------------------------- | --------------------------------------------------------------------------------------------------------- |
| babel-cli | Babel Command line interface |
| babel-core | Babel Core for transpiling the new JavaScript to old |
| babel-loader | Adds Babel support to Webpack |
| babel-preset-latest | Babel preset for running all the latest standardized JavaScript features |
| babel-register | Register Babel to transpile our Mocha tests |
| chai | Assertion library |
| chalk | Colored command line output |
| cheerio | Supports querying DOM with jQuery like syntax - Useful in testing and build process for HTML manipulation |
| compression | gzip http output |
| cross-env | Cross-environment friendly way to handle environment variables |
| css-loader | Add CSS support to Webpack |
| eslint | Lints JavaScript |
| eslint-plugin-import | Advanced linting of ES6 imports |
| eslint-watch | Add watch functionality to ESLint |
| express | Serves development and production builds |
| extract-text-webpack-plugin | Extracts CSS into separate file for production build |
| html-webpack-plugin | Generate HTML file programatically via Webpack |
| jsdom | In-memory DOM for testing |
| json-schema-faker | Declare a JSON schema for generating fake data |
| json-server | Serve a JSON API locally |
| localtunnel | Create a tunnel to your local machine |
| mocha | JavaScript testing library |
| nock | Mock HTTP requests via Node |
| npm-run-all | Display results of multiple commands on single command line |
| numeral | Library for working with numbers |
| open | Open app in default browser |
| rimraf | Delete files |
| style-loader | Add Style support to Webpack |
| webpack | Bundler with plugin system and integrated development server |
| webpack-dev-middleware | Adds middleware support to webpack |
| webpack-hot-middleware | Adds hot reloading to webpack |
| webpack-md5-hash | Used to hash files generated by Webpack using MD5 so that their names change when the content changes |
| **Dependency** | **Use** |
| ----------------------- | --------------------------------------------------------------------------------------------------------- |
| @babel/cli | Babel Command line interface |
| @babel/core | Babel Core for transpiling the new JavaScript to old |
| @babel/node | Run Babel via Node |
| @babel/preset-env | Babel preset for compiling to specific environments |
| @babel/register | Register Babel to transpile our Mocha tests |
| babel-loader | Adds Babel support to Webpack |
| chai | Assertion library |
| chalk | Colored command line output |
| cheerio | Supports querying DOM with jQuery like syntax - Useful in testing and build process for HTML manipulation |
| compression | gzip http output |
| cross-env | Cross-environment friendly way to handle environment variables |
| css-loader | Add CSS support to Webpack |
| eslint | Lints JavaScript |
| eslint-plugin-import | Advanced linting of ES6 imports |
| eslint-watch | Add watch functionality to ESLint |
| express | Serves development and production builds |
| faker | Generates realistic fake data |
| html-webpack-plugin | Generate HTML file programatically via Webpack |
| jsdom | In-memory DOM for testing |
| json-schema-faker | Declare a JSON schema for generating fake data |
| json-server | Serve a JSON API locally |
| mini-css-extract-plugin | Extract CSS to a separate file and minimize |
| mocha | JavaScript testing library |
| nock | Mock HTTP requests via Node |
| npm-run-all | Display results of multiple commands on single command line |
| numeral | Library for working with numbers |
| open | Open app in default browser |
| rimraf | Delete files |
| style-loader | Add Style support to Webpack |
| surge | Host a static site via a CLI command |
| webpack | Bundler with plugin system and integrated development server |
| webpack-dev-middleware | Adds middleware support to webpack |
| webpack-hot-middleware | Adds hot reloading to webpack |
| whatwg-fetch | Polyfill for the Browser's native fetch for older browsers |
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Test against this version of Node.js
environment:
matrix:
# node.js
- nodejs_version: "6"
# node.js
- nodejs_version: "14"

# Install scripts. (runs after repo cloning)
install:
Expand Down
29 changes: 17 additions & 12 deletions buildScripts/build.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
// More info on Webpack's Node API here: https://webpack.github.io/docs/node.js-api.html
// Allowing console calls below since this is a build file.
/*eslint-disable no-console */
import webpack from 'webpack';
import webpackConfig from '../webpack.config.prod';
import chalk from 'chalk';
import webpack from "webpack";
import webpackConfig from "../webpack.config.prod";
import chalk from "chalk";

process.env.NODE_ENV = 'production'; // this assures the Babel dev config doesn't apply.
process.env.NODE_ENV = "production"; // this assures the Babel dev config doesn't apply.

console.log(chalk.blue('Generating minified bundle for production. This will take a moment...'));
console.log(
chalk.blue(
"Generating minified bundle for production. This will take a moment..."
)
);

webpack(webpackConfig).run((err, stats) => {
if (err) { // so a fatal error occurred. Stop here.
if (err) {
// so a fatal error occurred. Stop here.
console.log(chalk.red(err));
return 1;
}

const jsonStats = stats.toJson();

if (jsonStats.hasErrors) {
return jsonStats.errors.map(error => console.log(chalk.red(error)));
return jsonStats.errors.map((error) => console.log(chalk.red(error)));
}

if (jsonStats.hasWarnings) {
console.log(chalk.yellow('Webpack generated the following warnings: '));
jsonStats.warnings.map(warning => console.log(chalk.yellow(warning)));
console.log(chalk.yellow("Webpack generated the following warnings: "));
jsonStats.warnings.map((warning) => console.log(chalk.yellow(warning)));
}

console.log(`Webpack stats: ${stats}`);

// if we got this far, the build succeeded.
console.log(chalk.green('Your app has been built for production and written to /dist!'));
console.log(
chalk.green("Your app has been built for production and written to /dist!")
);

return 0;
});
14 changes: 7 additions & 7 deletions buildScripts/buildHtml.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// This script copies src/index.html into /dist/index.html
// This is a good example of using Node and cheerio to do a simple file transformation.
// In this case, the transformation is useful since we only use a separate css file in prod.
import fs from 'fs';
import cheerio from 'cheerio';
import chalk from 'chalk';
import fs from "fs";
import cheerio from "cheerio";
import chalk from "chalk";

/*eslint-disable no-console */

fs.readFile('src/index.html', 'utf8', (err, markup) => {
fs.readFile("src/index.html", "utf8", (err, markup) => {
if (err) {
return console.log(err);
}

const $ = cheerio.load(markup);

// since a separate spreadsheet is only utilized for the production build, need to dynamically add this here.
$('head').prepend('<link rel="stylesheet" href="styles.css">');
$("head").prepend('<link rel="stylesheet" href="styles.css">');

fs.writeFile('dist/index.html', $.html(), 'utf8', function (err) {
fs.writeFile("dist/index.html", $.html(), "utf8", function (err) {
if (err) {
return console.log(err);
}
console.log(chalk.green('index.html written to /dist'));
console.log(chalk.green("index.html written to /dist"));
});
});
37 changes: 28 additions & 9 deletions buildScripts/distServer.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
import express from 'express';
import path from 'path';
import open from 'open';
import compression from 'compression';
import express from "express";
import path from "path";
import open from "open";
import compression from "compression";

/*eslint-disable no-console */
/* eslint-disable no-console */

const port = 3000;
const app = express();

app.use(express.static('dist'));
app.use(express.static("dist"));
app.use(compression());

app.get('*', function(req, res) {
res.sendFile(path.join(__dirname, '../dist/index.html'));
app.get("*", function (req, res) {
res.sendFile(path.join(__dirname, "../dist/index.html"));
});

app.listen(port, function(err) {
app.get("/users", function (req, res) {
// Hard coding for simplicity. Pretend this hits a real database
res.json([
{ id: 1, firstName: "Bob", lastName: "Smith", email: "[email protected]" },
{
id: 2,
firstName: "Tammy",
lastName: "Norton",
email: "[email protected]",
},
{
id: 3,
firstName: "Tina",
lastName: "Lee",
email: "[email protected]",
},
]);
});

app.listen(port, function (err) {
if (err) {
console.log(err);
} else {
Expand Down
12 changes: 7 additions & 5 deletions buildScripts/generateMockData.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

/* eslint-disable no-console */

import jsf from 'json-schema-faker';
import {schema} from './mockDataSchema';
import fs from 'fs';
import chalk from 'chalk';
import { generate, extend } from "json-schema-faker";
import { schema } from "./mockDataSchema";
import fs from "fs";
import chalk from "chalk";

const json = JSON.stringify(jsf(schema));
// Extend JSF with the fake libs you want to use.
extend("faker", () => require("faker"));
const json = JSON.stringify(generate(schema));

fs.writeFile("./src/api/db.json", json, function (err) {
if (err) {
Expand Down
53 changes: 26 additions & 27 deletions buildScripts/mockDataSchema.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
export const schema = {
"type": "object",
"properties": {
"users": {
"type": "array",
"minItems": 3,
"maxItems": 5,
"items": {
"type": "object",
"properties": {
"id": {
"type": "number",
"unique": true,
"minimum": 1
type: "object",
properties: {
users: {
type: "array",
minItems: 3,
maxItems: 5,
items: {
type: "object",
properties: {
id: {
type: "integer",
minimum: 1,
},
"firstName": {
"type": "string",
"faker": "name.firstName"
firstName: {
type: "string",
faker: "name.firstName",
},
"lastName": {
"type": "string",
"faker": "name.lastName"
lastName: {
type: "string",
faker: "name.lastName",
},
email: {
type: "string",
faker: "internet.email",
},
"email": {
"type": "string",
"faker": "internet.email"
}
},
"required": ["id", "firstName", "lastName", "email"]
}
}
required: ["id", "firstName", "lastName", "email"],
},
},
},
"required": ["users"]
required: ["users"],
};
Loading