Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sho1374k committed Aug 19, 2023
1 parent 05f2531 commit ac7ced5
Show file tree
Hide file tree
Showing 16 changed files with 341 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ pnpm-debug.log*

package-lock.json

_bk
_note
dist/
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package.json
package-lock.json
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false,
"semi": true,
"printWidth": 120
}
92 changes: 92 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { defineConfig } from "astro/config";
import postcssMergeQueries from "postcss-merge-queries";
import htmlMinify from "@frontendista/astro-html-minify";
import glsl from "vite-plugin-glsl";
import sitemap from "@astrojs/sitemap";
import * as dotenv from "dotenv";
dotenv.config();

function createDate() {
const now = new Date(),
year = now.getFullYear(),
month = now.getMonth() + 1,
date = now.getDate(),
hour = now.getHours(),
minute = now.getMinutes();
return `${year}${month}${date}${hour}${minute}`;
// return `${year}${month}${date}`;
}

const DATE = createDate(),
MODE = process.env.NODE_ENV,
SITE_URL = MODE === "production" ? process.env.PUBLIC_PROD_URL : process.env.PUBLIC_LOCAL_URL;
// ? process.env.PUBLIC_TEST_URL : process.env.PUBLIC_LOCAL_URL;
// ? process.env.PUBLIC_LOCAL_URL : process.env.PUBLIC_LOCAL_URL;

console.log(
`// --------------------------\n\n⚡️ ~ MODE : ${MODE}\n\n▕▔▔▔▔▔▔▔▔▔▔▔╲\n▕╮╭┻┻╮╭┻┻╮╭▕╮╲\n▕╯┃╭╮┃┃╭╮┃╰▕╯╭▏\n▕╭┻┻┻┛┗┻┻┛ ╰▏ ▏\n▕╰━━━┓┈┈┈╭╮▕╭╮▏\n▕╭╮╰┳┳┳┳╯╰╯▕╰╯▏\n▕╰╯┈┗┛┗┛┈╭╮▕╮┈▏\n\n// --------------------------`,
);

console.log(SITE_URL);

// https://astro.build/config
export default defineConfig({
markdown: {
drafts: true,
},
build: {
assets: "assets",
},
site: SITE_URL,
base: "/",
vite: {
plugins: [glsl()],
esbuild: {
drop: ["console", "debugger"],
},
build: {
assetsInlineLimit: 0,
chunkSizeWarningLimit: 100000000,
rollupOptions: {
output: {
assetFileNames: `assets/[ext]/[name].${DATE}[extname]`,
entryFileNames: `assets/js/build.${DATE}.js`,
},
},
cssCodeSplit: false,
},
css: {
postcss: {
plugins: [postcssMergeQueries],
},
},
server: {
open: true,
port: 8080,
},
preview: {
open: true,
port: 8080,
},
},
integrations: [
sitemap(),
htmlMinify({
reportCompressedSize: false,
htmlTerserMinifierOptions: {
removeComments: true,
removeTagWhitespace: false,
},
}),
],
server: {
open: true,
host: true,
port: 3000,
},
preview: {
open: true,
host: true,
port: 3000,
},
});
3 changes: 3 additions & 0 deletions postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: [require("autoprefixer")],
};
50 changes: 50 additions & 0 deletions replaceHtml.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { writeFileSync, readFileSync } from "fs";
import glob from "glob";

const replaceInHtmlFiles = () => {
try {
const files = glob.sync("dist/**/*.html");
console.log(files);
for (const file of files) {
// htmlファイルの読み込み
const data = readFileSync(file, "utf8");

// htmlの置かれているパスから相対(., ..)を算出
let relativePath = file.replace(/[^/]/g, "").replace(/\//g, ".");

if (relativePath.length === 1) {
relativePath = file.replace(/[^/]/g, "").replace(/\//g, ".");
} else {
relativePath = file.replace(/[^/]/g, "").replace(/\//g, "../");
relativePath = relativePath.slice(0, -1);
// 3 ... | ../../ → ../..
// 4 .... | ../../../ → ../../..
// 5 ..... | ../../../../ → ../../../..
}

// href, srcに指定されている絶対パスを置換
const result = data
.replace(/href="\//g, `href="${relativePath}/`)
.replace(/href='\//g, `href='${relativePath}/`)
.replace(/src="\//g, `src="${relativePath}/`)
.replace(/src='\//g, `src='${relativePath}/`)
.replace(/srcset="\//g, `srcset="${relativePath}/`)
.replace(/srcset='\//g, `srcset='${relativePath}/`)
.replace(/action="\//g, `action="${relativePath}/`)
.replace(/action='\//g, `action='${relativePath}/`)
.replace(/content="\//g, `content="${relativePath}/`)
.replace(/content='\//g, `content='${relativePath}/`);

writeFileSync(file, result, "utf8");
// console.log(file);
}
console.log(`\n// --------------------------\n\n👌 ~ replaceInHtmlFiles\n\n// --------------------------\n`);
} catch (error) {
console.log(
`\n// -------------------------- \n\n🙅‍♀️ ~ replaceInHtmlFiles\n\n// --------------------------\n${error}\n`,
);
}
};

replaceInHtmlFiles();
// node replaceHtml.mjs
4 changes: 3 additions & 1 deletion src/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ window.addEventListener("DOMContentLoaded", (e) => {

webgl.resize(params);
};
resize();
window.addEventListener("resize", resize, { passive: true });
setTimeout(() => {
resize();
}, 300);

if (bool.isMatchMediaHover) {
// 右クリック禁止
Expand Down
4 changes: 2 additions & 2 deletions src/assets/js/webgl/WebGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export class WebGL {
}

resize(params) {
this.params.w = this.params.w;
this.params.h = this.params.h;
this.params.w = params.w;
this.params.h = params.h;

this.stage.resize(params.w, params.h);
this.plane.resize(params);
Expand Down
156 changes: 156 additions & 0 deletions src/assets/scss/foundation/_reset.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
@use "../global/function" as *;

html,
body {
font-family: var(--ja);
font-weight: 400;
font-size: calc(100 / var(--base-vw) * 1vw);
@include pc_w() {
--base-vw: 1440;
}
@include sp_w() {
--base-vw: 375;
}
color: var(--black);
background: var(--white);
background-size: cover;
background-repeat: no-repeat;
overscroll-behavior: none;
}

body,
div,
dl,
dt,
dd,
ul,
ol,
li,
h1,
h2,
h3,
h4,
h5,
h6,
p,
pre,
code,
form,
fieldset,
legend,
input,
textarea,
blockquote,
th,
td,
p {
margin: 0;
padding: 0;
}

table {
border-collapse: collapse;
border-spacing: 0;
}

iframe,
fieldset,
img {
border: 0;
}

address,
caption,
cite,
code,
dfn,
em,
strong,
th,
var {
font-style: normal;
font-weight: normal;
}

ol,
ul {
list-style: none;
}

caption,
th {
text-align: left;
}

abbr,
acronym {
border: 0;
font-variant: normal;
}

sup {
vertical-align: text-top;
}

sub {
vertical-align: text-bottom;
}

input,
textarea,
select {
font-family: inherit;
font-size: inherit;
font-weight: inherit;
}

legend {
color: var(--black);
}

*:focus {
outline: none;
}

a {
cursor: pointer;
color: var(--black);
text-decoration: none;
box-shadow: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

input {
cursor: pointer;
-webkit-appearance: none;
appearance: none;
background-color: #fff;
border-radius: 0;
}

textarea {
cursor: pointer;
-webkit-appearance: none;
appearance: none;
border-radius: 0;
resize: vertical;
}

select {
cursor: pointer;
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
background: none;
border: none;
}

button {
cursor: pointer;
border: none;
background: initial;
}

::-webkit-scrollbar {
display: none;
}
3 changes: 3 additions & 0 deletions src/assets/scss/global/_app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// entry point
@forward "./function";
@forward "./variable";
2 changes: 1 addition & 1 deletion src/assets/shader/frag/plane.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ void main() {
vec4 texture = mix(t1,t2,interpolation);
vec4 dist = vec4(texture.rgb * matcapTexture.rgb, 1.0);
gl_FragColor = dist;
}
}
1 change: 1 addition & 0 deletions src/assets/shader/vert/plane.glsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

attribute vec3 position;
attribute vec3 normal;
attribute vec2 uv;
Expand Down
9 changes: 9 additions & 0 deletions src/components/Copyright.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
---

<a
class="c-copyright"
href="https://dev.shoya-kajita.com/"
target="_blank"
rel="noopener noreferrer">©2023 SHOYA KAJITA.</a
>
1 change: 1 addition & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="astro/client" />
Loading

0 comments on commit ac7ced5

Please sign in to comment.