DIY
Webpack
typescript
{
"include": ["src", "types"] /* */,
"exclude": ["node_modules"],
"compilerOptions": {
"target": "ESNEXT" /* 直接输出为最新的 ES 标准 */,
"module": "ESNEXT" /* 面向未来的 ESM 模块化 */,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false /* 不允许导入js文件 */,
"jsx": "react-jsx" /* react17后 选择这个就好了 */,
"outDir": "./build" /* 打包路径 */,
"strict": true /* 开启严格模式 */,
"noImplicitAny": true /* 不能用any类型 */,
"moduleResolution": "node" /* 模块解析策略 这里我们使用node */,
"baseUrl": "./" /* 配置根路径 比如下面的typeRoots和最上面的include exclude都会加上这个路径 */,
"typeRoots": [
"node_modules/@types",
"types/*.d.ts"
] /* 默认会引入@types下的类型类型声明文件 可以配置这项加入一些自己定义的类型 */,
"allowSyntheticDefaultImports": true /* 即使一个模块没有默认导入 也可以使用默认导入 */,
"esModuleInterop": true /* https://zhuanlan.zhihu.com/p/148081795 */,
"experimentalDecorators": true /* 开启装饰器语法 */,
"skipLibCheck": false /* 跳过所有.d.ts文件的类型检查 */,
"forceConsistentCasingInFileNames": true
}
}webpack
webpack.config.dev.js 的配置如下
webpack.config.dev.js 的配置如下webpack.config.prod.js 配置如下
webpack.config.prod.js 配置如下eslint
prettier
FAQ
Cannot find module './app.module.scss' or its corresponding type declarations.
eslint
yarn start 🎉 🎉 🎉 🎉 🎉
Vite
typescript
scss
eslint | prettier 同上
vite
FAQ 同上
yarn dev 🎉 🎉 🎉 🎉 🎉
Snowpack
snowpack
yarn start 🎉 🎉 🎉 🎉 🎉
Git


🎉 🎉 🎉
Last updated