mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-26 14:20:43 -05:00
feat: adding git ignore/webpack tutorial
This commit is contained in:
parent
1fcb68f4e4
commit
5e71ed17da
12 changed files with 4453 additions and 0 deletions
131
.gitignore
vendored
Normal file
131
.gitignore
vendored
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
# 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.*
|
||||||
|
|
4187
dom-exercise/webpack-demo/package-lock.json
generated
Normal file
4187
dom-exercise/webpack-demo/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
30
dom-exercise/webpack-demo/package.json
Normal file
30
dom-exercise/webpack-demo/package.json
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "webpack-demo",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"watch": "webpack --watch",
|
||||||
|
"start": "webpack serve --open --config webpack.dev.js",
|
||||||
|
"server": "node server.js",
|
||||||
|
"build": "webpack --config webpack.prod.js"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"css-loader": "^6.8.1",
|
||||||
|
"express": "^4.18.2",
|
||||||
|
"html-webpack-plugin": "^5.5.4",
|
||||||
|
"style-loader": "^3.3.3",
|
||||||
|
"webpack": "^5.89.0",
|
||||||
|
"webpack-cli": "^5.1.4",
|
||||||
|
"webpack-dev-middleware": "^6.1.1",
|
||||||
|
"webpack-dev-server": "^4.15.1",
|
||||||
|
"webpack-merge": "^5.10.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"lodash": "^4.17.21"
|
||||||
|
}
|
||||||
|
}
|
17
dom-exercise/webpack-demo/server.js
Normal file
17
dom-exercise/webpack-demo/server.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
const express = require('express');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const webpackDevMiddleware = require('webpack-dev-middleware');
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
const config = require('./webpack.config.js');
|
||||||
|
const compiler = webpack(config);
|
||||||
|
|
||||||
|
app.use(
|
||||||
|
webpackDevMiddleware(compiler, {
|
||||||
|
publicPath: config.output.publicPath,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
app.listen(3000, function () {
|
||||||
|
console.log('Example app listening on port 3k');
|
||||||
|
});
|
3
dom-exercise/webpack-demo/src/functionOne.js
Normal file
3
dom-exercise/webpack-demo/src/functionOne.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
const functionOne = () => console.log('FUNCTION ONE');
|
||||||
|
|
||||||
|
export { functionOne };
|
BIN
dom-exercise/webpack-demo/src/gitlab.png
Normal file
BIN
dom-exercise/webpack-demo/src/gitlab.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
28
dom-exercise/webpack-demo/src/index.js
Normal file
28
dom-exercise/webpack-demo/src/index.js
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import _ from 'lodash';
|
||||||
|
import printMe from './print';
|
||||||
|
import './style.css';
|
||||||
|
import Icon from './gitlab.png';
|
||||||
|
import { functionOne } from './functionOne';
|
||||||
|
|
||||||
|
function component() {
|
||||||
|
const element = document.createElement('div');
|
||||||
|
const btn = document.createElement('button');
|
||||||
|
|
||||||
|
element.innerHTML = _.join(['Hello', 'webpack'], ' ');
|
||||||
|
element.classList.add('hello');
|
||||||
|
|
||||||
|
// add image to our file
|
||||||
|
const myIcon = new Image();
|
||||||
|
myIcon.src = Icon;
|
||||||
|
|
||||||
|
btn.innerHTML = 'Click me and check the console!';
|
||||||
|
btn.onclick = printMe;
|
||||||
|
|
||||||
|
element.appendChild(myIcon);
|
||||||
|
element.appendChild(btn);
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
functionOne();
|
||||||
|
document.body.appendChild(component());
|
3
dom-exercise/webpack-demo/src/print.js
Normal file
3
dom-exercise/webpack-demo/src/print.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default function printMe() {
|
||||||
|
console.log('I get called from print.js!');
|
||||||
|
}
|
3
dom-exercise/webpack-demo/src/style.css
Normal file
3
dom-exercise/webpack-demo/src/style.css
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
.hello {
|
||||||
|
color: red;
|
||||||
|
}
|
35
dom-exercise/webpack-demo/webpack.common.js
Normal file
35
dom-exercise/webpack-demo/webpack.common.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
const path = require('path');
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: {
|
||||||
|
index: './src/index.js',
|
||||||
|
print: './src/print.js'
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
title: 'Development',
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
output: {
|
||||||
|
filename: '[name].bundle.js',
|
||||||
|
path: path.resolve(__dirname, 'dist'),
|
||||||
|
clean: true,
|
||||||
|
publicPath: '/',
|
||||||
|
},
|
||||||
|
optimization: {
|
||||||
|
runtimeChunk: 'single',
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.css$/i,
|
||||||
|
use: ['style-loader', 'css-loader'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(png|svg|jp|jpeg|gif)$/i,
|
||||||
|
type: 'asset/resource',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
10
dom-exercise/webpack-demo/webpack.dev.js
Normal file
10
dom-exercise/webpack-demo/webpack.dev.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
const { merge } = require('webpack-merge');
|
||||||
|
const common = require('./webpack.common.js');
|
||||||
|
|
||||||
|
module.exports = merge(common, {
|
||||||
|
mode: 'development',
|
||||||
|
devtool: 'inline-source-map',
|
||||||
|
devServer: {
|
||||||
|
static: './dist',
|
||||||
|
},
|
||||||
|
});
|
6
dom-exercise/webpack-demo/webpack.prod.js
Normal file
6
dom-exercise/webpack-demo/webpack.prod.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
const { merge } = require('webpack-merge');
|
||||||
|
const common = require('./webpack.common.js');
|
||||||
|
|
||||||
|
module.exports = merge(common, {
|
||||||
|
mode: 'production',
|
||||||
|
});
|
Loading…
Reference in a new issue