refactor: directory structure for server and web

This commit is contained in:
tsukino
2024-02-20 21:46:22 +08:00
committed by tsukino
parent 2b7b747266
commit 7ddd5674ca
28 changed files with 13 additions and 12 deletions

View File

@@ -3,6 +3,6 @@ node_modules
wasm wasm
tlsn tlsn
postcss.config.js postcss.config.js
webpack.config.js webpack.web.config.js
*.json *.json
*.scss *.scss

View File

@@ -4,12 +4,12 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build:ui": "NODE_ENV=production webpack --config webpack.config.js", "build:ui": "NODE_ENV=production webpack --config webpack.web.config.js",
"build:server": "NODE_ENV=production webpack --config webpack.server.config.js", "build:server": "NODE_ENV=production webpack --config webpack.server.config.js",
"watch:server": "webpack --config webpack.server.config.js --watch", "watch:server": "webpack --config webpack.server.config.js --watch",
"nodemon:server": "nodemon build/server/index.js", "nodemon:server": "nodemon build/server/index.bundle.js",
"dev:server": "NODE_ENV=development concurrently npm:watch:server npm:nodemon:server", "dev:server": "NODE_ENV=development concurrently npm:watch:server npm:nodemon:server",
"dev:ui": "NODE_ENV=development webpack-dev-server --config webpack.config.js --hot" "dev:ui": "NODE_ENV=development webpack-dev-server --config webpack.web.config.js --hot"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@@ -1,3 +1,3 @@
import express from 'express'; import express from 'express';
console.log('hi') console.log('hi');

View File

@@ -1,6 +1,6 @@
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
module.exports = { module.exports = {
content: ['./src/**/*.{js,jsx,ts,tsx}'], content: ['./web/**/*.{js,jsx,ts,tsx}'],
theme: { theme: {
extend: { extend: {
colors: { colors: {

View File

@@ -15,6 +15,8 @@
"noEmit": false, "noEmit": false,
"jsx": "react" "jsx": "react"
}, },
"include": ["src"], "include": [
"web"
],
"exclude": ["build", "node_modules"] "exclude": ["build", "node_modules"]
} }

View File

@@ -37,7 +37,6 @@ var options = {
], ],
}, },
plugins: [ plugins: [
isDevelopment && new ReactRefreshWebpackPlugin(),
new CleanWebpackPlugin({ verbose: false }), new CleanWebpackPlugin({ verbose: false }),
new webpack.ProgressPlugin(), new webpack.ProgressPlugin(),
new webpack.EnvironmentPlugin(["NODE_ENV"]), new webpack.EnvironmentPlugin(["NODE_ENV"]),

View File

@@ -33,11 +33,11 @@ var options = {
/ResizeObserver loop completed with undelivered notifications/ /ResizeObserver loop completed with undelivered notifications/
], ],
entry: { entry: {
index: path.join(__dirname, "src", "index.tsx"), index: path.join(__dirname, "web", "index.tsx"),
}, },
output: { output: {
filename: "[name].bundle.js", filename: "[name].bundle.js",
path: path.resolve(__dirname, "build"), path: path.resolve(__dirname, "build", "ui"),
clean: true, clean: true,
publicPath: ASSET_PATH, publicPath: ASSET_PATH,
}, },
@@ -46,7 +46,7 @@ var options = {
{ {
// look for .css or .scss files // look for .css or .scss files
test: /\.(css|scss)$/, test: /\.(css|scss)$/,
// in the `src` directory // in the `web` directory
use: [ use: [
{ {
loader: "style-loader", loader: "style-loader",
@@ -132,7 +132,7 @@ var options = {
patterns: [ patterns: [
{ {
from: "node_modules/tlsn-js/build", from: "node_modules/tlsn-js/build",
to: path.join(__dirname, "build"), to: path.join(__dirname, "build", "ui"),
force: true, force: true,
}, },
] ]