Initial commit - project start

npm, package.json, webpack, boilerplate, hello world
This commit is contained in:
NetMan 2024-02-03 19:56:39 +01:00
commit 4459f7dbe4
10 changed files with 4485 additions and 0 deletions

135
.gitignore vendored Normal file
View File

@ -0,0 +1,135 @@
####
#### NODE .GITIGNORE
#### FROM: https://github.com/github/gitignore/blob/main/Node.gitignore
####
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

9
README.md Normal file
View File

@ -0,0 +1,9 @@
# odin-restaurant
Project using npm & webpack
## setup
to build for production: `npm run build`
to launch dev server: `npm run dev`

4238
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

24
package.json Normal file
View File

@ -0,0 +1,24 @@
{
"name": "odin-restaurant",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --progress --config webpack.prod.js",
"dev": "webpack-dev-server --progress --config webpack.dev.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"css-loader": "^6.10.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.6.0",
"style-loader": "^3.3.4",
"webpack": "^5.90.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.10.0"
}
}

9
src/main.js Normal file
View File

@ -0,0 +1,9 @@
import "./style.css"
const app = document.querySelector("#app");
let welcome = document.createElement("span");
welcome.id = "welcome";
welcome.textContent = "Welcome to the restaurant website";
app.append(welcome);

5
src/style.css Normal file
View File

@ -0,0 +1,5 @@
#welcome {
font-size: 2rem;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
color: #611;
}

11
src/template.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Restaurant</title>
</head>
<body>
<div id="app"></div>
</body>
</html>

32
webpack.common.js Normal file
View File

@ -0,0 +1,32 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/main.js',
output: {
filename: "bundle.js",
clean: true,
path: path.resolve(__dirname, "dist"),
},
module: {
rules: [
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(jpg|png|gif|jpeg|webp)$/i,
use: ['file-loader'],
},
{
test: /\.(woff|woff2|otf|ttf|eot)$/i,
type: "asset/resource",
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/template.html",
})
]
}

7
webpack.dev.js Normal file
View File

@ -0,0 +1,7 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: "production",
devtool: "source-map",
})

15
webpack.prod.js Normal file
View File

@ -0,0 +1,15 @@
const path = require('path');
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: "development",
devtool: "inline-source-map",
devSources: {
static: {
directory: path.join(__dirname, "src"),
},
compress: true,
port: 9001,
}
})