Added @type alias, separated constants.ts file
This commit is contained in:
parent
74b3cc725d
commit
02453c8cf6
@ -1,6 +1,6 @@
|
||||
{
|
||||
"scripts": {
|
||||
"dev": "SNOWPACK_PUBLIC_API_URL=https://publitebackend.dmitriy.icu snowpack dev",
|
||||
"dev": "SNOWPACK_PUBLIC_API_URL=https://publitebackend.dmitriy.icu SNOWPACK_PUBLIC_BASE_URL=http://localhost:8080 snowpack dev",
|
||||
"build": "snowpack build",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
|
@ -21,7 +21,11 @@ module.exports = {
|
||||
devOptions: {
|
||||
open: "none",
|
||||
},
|
||||
alias: { "@assets": "./src/assets", "@utils": "./src/utils" },
|
||||
alias: {
|
||||
"@assets": "./src/assets",
|
||||
"@utils": "./src/utils",
|
||||
"@type": "./src/type",
|
||||
},
|
||||
exclude: ["**/node_modules/**/*", "**/*.test.*"],
|
||||
env: {
|
||||
// API_URL: "https://publitebackend.dmitriy.icu",
|
||||
|
@ -2,7 +2,7 @@ import React from "react";
|
||||
|
||||
import styles from "./BookItem.module.css";
|
||||
|
||||
import { IBook } from "../../types/book";
|
||||
import { IBook } from "@type/book";
|
||||
|
||||
interface IBookItemProps extends IBook {}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import React, { useState } from "react";
|
||||
import { IBook } from "../types/book";
|
||||
import { IBook } from "@type/book";
|
||||
|
||||
import styles from "./Bookshelf.module.css";
|
||||
|
||||
import list from "../assets/bookList.json";
|
||||
import list from "@assets/bookList.json";
|
||||
import { BookItem } from "./BookItem";
|
||||
import { AddBook } from "./AddBook";
|
||||
|
||||
@ -21,5 +21,3 @@ export const Bookshelf = () => {
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Bookshelf;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { IBook, optionalBookProps, requiredBookProps } from "./types/book";
|
||||
import { IBook, optionalBookProps, requiredBookProps } from "@type/book";
|
||||
|
||||
const API_URL = import.meta.env.SNOWPACK_PUBLIC_API_URL;
|
||||
import { API_URL } from "./constants";
|
||||
|
||||
export const validState = (file: File | undefined): file is File => {
|
||||
if (!file) throw new Error("Book file is required. Please, attach one");
|
||||
|
2
src/constants.ts
Normal file
2
src/constants.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export const API_URL = import.meta.env.SNOWPACK_PUBLIC_API_URL;
|
||||
export const BASE_URL = import.meta.env.SNOWPACK_PUBLIC_BASE_URL;
|
@ -1,5 +1,5 @@
|
||||
import { IBook } from "../types/book";
|
||||
import { isArrOfStr } from "../types/utils";
|
||||
import { IBook } from "@type/book";
|
||||
import { isArrOfStr } from "@type/utils";
|
||||
|
||||
export const saveBook = (bookObj: IBook, key: string): void => {
|
||||
const bookListStr = localStorage.getItem("list") || "[]";
|
||||
|
@ -10,6 +10,10 @@
|
||||
"module": "ES2020",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"paths": { "@assets/*": ["./src/assets/*"], "@utils/*": ["./src/utils/*"] }
|
||||
"paths": {
|
||||
"@assets/*": ["./src/assets/*"],
|
||||
"@utils/*": ["./src/utils/*"],
|
||||
"@type/*": ["./src/type/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user