Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita33accd

Browse files
committed
update readme
1 parent39b7db0 commita33accd

File tree

1 file changed

+26
-42
lines changed

1 file changed

+26
-42
lines changed

‎readme.md‎

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
***Eslint** helps practice standard coding styles
1212

1313
##Versions
14-
* NextJs v9.3.6
15-
* Redux-Toolkit v1.3.5
14+
* NextJs v9.4.2
15+
* Redux-Toolkit v1.3.6
1616
* Emotion v10
17-
* Typescript v3.8.3
17+
* Typescript v3.9.2
1818

1919
##Other Project Setup
2020
***[[Nextjs_Ts_Eslint]](https://github.com/Project-Setup/Nextjs_Ts_Eslint)** NextJs, EmotionJs, Typescript
@@ -29,12 +29,12 @@
2929
npm install
3030
```
3131
1. remove unwanted filesin`public/`,`src/`
32-
2.modify`configs/` andadd`.env/`
32+
2.add`.env` andother.env files
3333
3. preview dev progress on`http://localhost:3000/`
3434
```sh
3535
npm run dev
3636
```
37-
4.export to`docs/`forGIthub Page deploy
37+
4.export to`docs/`forGithub Page deploy
3838
```sh
3939
npm runexport
4040
```
@@ -108,7 +108,8 @@
108108
"skipLibCheck": true,
109109
"strict": true,
110110
"target":"esnext",
111-
"forceConsistentCasingInFileNames":true
111+
"forceConsistentCasingInFileNames": true,
112+
"baseUrl":"./src"
112113
},
113114
"exclude": [
114115
"node_modules",
@@ -129,7 +130,7 @@
129130
### [Eslint and Prettier](https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-typescript-project-53jb)
130131
1.
131132
```sh
132-
npm i -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react
133+
npm i -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-import-resolver-typescript
133134
npm i -D eslint-config-airbnb eslint-plugin-jsx-a11y eslint-plugin-import eslint-plugin-react-hooks
134135
npm i -D prettier eslint-config-prettier eslint-plugin-prettier
135136
```
@@ -205,6 +206,7 @@
205206
node: {
206207
extensions: ['.js','.jsx','.ts','.tsx'],
207208
},
209+
typescript: {},
208210
},
209211
react: {
210212
version:'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
@@ -268,6 +270,7 @@
268270
'<rootDir>/__mocks__/mocks.js',
269271
'\\.(css|less|scss)$':'<rootDir>/__mocks__/mocks.js',
270272
},
273+
moduleDirectories: ['node_modules','src'],
271274
};
272275
```
273276
5. create`babel.config.js`
@@ -280,6 +283,11 @@
280283
```js
281284
import Enzyme from'enzyme';
282285
import Adapter from'enzyme-adapter-react-16';
286+
import { join } from'path';
287+
import { loadEnvConfig } from'next/dist/lib/load-env-config';
288+
289+
// to load'.env' filesintest
290+
loadEnvConfig(join(__dirname,'.../'));
283291
284292
Enzyme.configure({ adapter: newAdapter() });
285293
```
@@ -349,19 +357,19 @@
349357
### [Deploy to Github Pages](https://github.com/zeit/next.js/issues/3335#issuecomment-489354854)
350358
(deploy to /docs intead of using gh-pages branch; replace`{folder}` with the project namein github repo)
351359
352-
1. create`LINK_PREFIX`in`next.config.js`
360+
1. add`.env.production`
361+
```sh
362+
NEXT_PUBLIC_LINK_PREFIX=/{folder}
363+
```
364+
2. create`LINK_PREFIX`in`next.config.js`
353365
```js
354-
const isProd = process.env.NODE_ENV ==='production';
355-
const prodAssetPrefix ='/{folder}';
366+
const LINK_PREFIX = process.env.NEXT_PUBLIC_LINK_PREFIX||'';
356367
module.exports = () => ({
357-
env: {
358-
LINK_PREFIX: isProd? prodAssetPrefix:'';
359-
},
360-
assetPrefix: isProd? prodAssetPrefix:'';,
368+
assetPrefix: LINK_PREFIX,
361369
});
362370
```
363-
2. change`as` propin`next/Link` to add`linkPrefix`, similar to`src/features/link/Link.tsx`in the example setup
364-
3. change`scripts`in`package.json`
371+
3. change`as` propin`next/Link` to add`linkPrefix`, similar to`src/features/link/Link.tsx`in the example setup
372+
4. change`scripts`in`package.json`
365373
```json
366374
{
367375
"scripts": {
@@ -391,31 +399,6 @@
391399
};
392400
```
393401
394-
### Dotenv
395-
1.
396-
```sh
397-
npm i -S dotenv
398-
```
399-
2. add`.env/development.env` and`.env/production.env`
400-
3. add`config/env.mapping.js`
401-
```js
402-
/* eslint-disable @typescript-eslint/no-var-requires*/
403-
const path = require('path');
404-
require('dotenv').config({
405-
path: path.join(__dirname,`../.env/${process.env.NODE_ENV}.env`),
406-
});
407-
408-
// env mappingfor exposure to client
409-
module.exports = {/* EXAMPLE_VAR: process.env.EXAMPLE*/};
410-
```
411-
4. add to`jest/jest.setup.js`
412-
```js
413-
// ...
414-
import envMapping from'../configs/env.mapping';
415-
Object.assign(process.env, envMapping);
416-
// ...
417-
```
418-
419402
<br/>
420403
421404
### [Redux-Toolkit](https://redux-toolkit.js.org/)
@@ -439,6 +422,7 @@
439422
2. change`next.config.js`
440423
```js
441424
const isProd = process.env.NODE_ENV ==='production';
425+
const FOLDER = LINK_PREFIX&& LINK_PREFIX.substring(1);
442426
443427
// tranfrom precache urlfor browsers that encode dynamic routes
444428
// i.e."[id].js" =>"%5Bid%5D.js"
@@ -458,7 +442,7 @@
458442
// service worker
459443
pwa: {
460444
disable: !isProd,
461-
subdomainPrefix:proces.env.LINK_PREFIX,
445+
subdomainPrefix: LINK_PREFIX,
462446
dest: 'public',
463447
navigationPreload: true,
464448
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp