Began working on the toolchain
This commit is contained in:
@@ -102,3 +102,10 @@ dist
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Output files
|
||||
public/*.html
|
||||
public/*.js
|
||||
public/*.css
|
||||
public/*.map
|
||||
public/*.gz
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
console.log("Hello world!");
|
||||
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang = "en">
|
||||
<head>
|
||||
<!-- device settings -->
|
||||
<meta charset = "UTF-8" />
|
||||
<meta name="Content-Type" content="text/html" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<!-- page title -->
|
||||
<title>MERN template</title>
|
||||
|
||||
<!-- page information -->
|
||||
<meta name="description" content="MERN template" />
|
||||
<meta name="author" content="Kayne Ruse" />
|
||||
<meta name="keywords" content="" />
|
||||
|
||||
<!-- facebook? -->
|
||||
<meta property="og:url" content="" />
|
||||
<meta property="og:type" content="" />
|
||||
<meta property="og:image" content="" />
|
||||
<meta property="og:title" content="MERN template" />
|
||||
<meta property="og:description" content="" />
|
||||
</head>
|
||||
<body>
|
||||
<div id = "root"></div>
|
||||
</body>
|
||||
</html>
|
||||
Generated
+3172
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "mern-template",
|
||||
"version": "1.0.0",
|
||||
"description": "A website template using the MERN stack.",
|
||||
"main": "server/server.js",
|
||||
"scripts": {
|
||||
"start": "npm run build && node server/server.js",
|
||||
"dev": "npm run build && nodemon server/server.js",
|
||||
"build": "npm run build:server && npm run build:client",
|
||||
"build:server": "exit 0",
|
||||
"build:client": "webpack --env=production --config webpack.config.js",
|
||||
"analyzer": "webpack --env=production --analyzer --config webpack.config.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/KRGameStudios/MERN-template.git"
|
||||
},
|
||||
"author": "Kayne Ruse",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/KRGameStudios/MERN-template/issues"
|
||||
},
|
||||
"homepage": "https://github.com/KRGameStudios/MERN-template#readme",
|
||||
"dependencies": {
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"html-webpack-plugin": "^5.0.0-alpha.14",
|
||||
"nodemon": "^2.0.7",
|
||||
"webpack": "^5.15.0",
|
||||
"webpack-bundle-analyzer": "^4.3.0",
|
||||
"webpack-cli": "^4.3.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//environment variables
|
||||
require('dotenv').config();
|
||||
|
||||
//create the server
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const http = require('http').Server(app);
|
||||
|
||||
//libraries used here
|
||||
const path = require('path');
|
||||
|
||||
//send static files
|
||||
app.use('/', express.static(path.resolve(__dirname, '../public')));
|
||||
|
||||
//fallback to the index file
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname, `../public/index.html`));
|
||||
});
|
||||
|
||||
//startup
|
||||
http.listen(process.env.WEB_PORT || 3000, (err) => {
|
||||
console.log(`listening to localhost:${process.env.WEB_PORT || 3000}`);
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
//plugins
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
|
||||
//libraries
|
||||
const path = require('path');
|
||||
|
||||
//the exported config function
|
||||
module.exports = ({ production, analyzer }) => {
|
||||
|
||||
return {
|
||||
mode: production ? "production" : "development",
|
||||
entry: path.resolve(__dirname, 'client', 'client.js'),
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'public'),
|
||||
filename: '[name].[chunkhash].js'
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.jsx']
|
||||
},
|
||||
plugins: [
|
||||
new CleanWebpackPlugin({
|
||||
cleanOnceBeforeBuildPatterns: ['*', '!content*']
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
template: "./client/template.html",
|
||||
minify: {
|
||||
collapseWhitespace: production,
|
||||
removeComments: production,
|
||||
removeAttributeQuotes: production
|
||||
}
|
||||
}),
|
||||
new BundleAnalyzerPlugin({
|
||||
analyzerMode: analyzer ? 'server' : 'disabled'
|
||||
})
|
||||
]
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user