Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
c981883
feat: reborn of the project
zzyueb Feb 4, 2024
20af1ce
feat: reborn of the project
zzyueb Feb 4, 2024
db1ad7c
Merge branch 'dev'
zzyueb Feb 4, 2024
9d8076b
fix: delete style-resource-loader config because it will trigger the …
zzyueb Feb 4, 2024
d6c5b42
Merge branch 'dev'
zzyueb Feb 4, 2024
ea9b5ce
feat: reborn of the project
zzyueb Feb 4, 2024
3821397
fix: merge dev
zzyueb Feb 4, 2024
c89a5a0
feat: add createAlias hook
zzyueb Feb 4, 2024
e8b1e5f
Merge branch 'dev'
zzyueb Feb 4, 2024
8139c1e
feat: add createAlias hook
zzyueb Feb 4, 2024
d3a6465
Merge branch 'dev'
zzyueb Feb 4, 2024
65526be
perf: simplify code
zzyueb Feb 4, 2024
4eb8791
Merge branch 'dev'
zzyueb Feb 4, 2024
3f4dc0e
feat: add devtool
zzyueb Feb 5, 2024
195b6a3
feat: unique styl and stylus
zzyueb Feb 6, 2024
358391b
Merge branch 'dev'
zzyueb Feb 6, 2024
f4fd2b1
perf: delete unused docs
zzyueb Feb 6, 2024
5a7def0
Merge branch 'dev'
zzyueb Feb 6, 2024
b33d885
fix: getOnePluginConfig bugfix and make immutable configurations
zzyueb Feb 6, 2024
6200f7e
Merge branch 'dev'
zzyueb Feb 6, 2024
ad707c1
chore: package-lock
zzyueb Feb 6, 2024
c8e4018
perf: add license
zzyueb Feb 7, 2024
11e18d6
feat: add '#' as an alias of './types' and add RFC type to replace Re…
zzyueb Feb 7, 2024
b4d6ab9
fix: add css-module hash rule
zzyueb Feb 7, 2024
98db1f7
perf: change name
zzyueb Feb 7, 2024
b19b9f1
fix: add css-module hash rule and reset resolve
zzyueb Feb 7, 2024
b343d19
Merge branch 'dev'
zzyueb Feb 7, 2024
1e46023
fix: add css-module hash rule and reset resolve
zzyueb Feb 7, 2024
59fe8e5
Merge branch 'dev'
zzyueb Feb 7, 2024
16ca6f7
fix: NODE_ENV mistake
zzyueb Feb 7, 2024
5d5945c
Merge branch 'dev'
zzyueb Feb 7, 2024
4b31009
fix: isProd
zzyueb Feb 7, 2024
8a91e21
Merge branch 'dev'
zzyueb Feb 7, 2024
268dd66
chore: add editorconfig
zzyueb Feb 7, 2024
4b1b451
Merge branch 'dev'
zzyueb Feb 7, 2024
fbf3e1d
docs: English rewrite
zzyueb Feb 7, 2024
f344c14
Merge branch 'dev'
zzyueb Feb 7, 2024
b72d24a
fix: simplify
zzyueb Feb 7, 2024
43c671d
Merge branch 'dev'
zzyueb Feb 7, 2024
714695c
fix: change function
zzyueb Feb 9, 2024
f5cc0c9
Merge branch 'dev'
zzyueb Feb 9, 2024
291af7b
docs: add yarn and pnpm
zzyueb Feb 9, 2024
4ebbabe
Merge branch 'dev'
zzyueb Feb 9, 2024
449acfa
fix: some mistakes
zzyueb Feb 9, 2024
0ff0748
fix: css module bug
zzyueb Feb 11, 2024
aa84c78
Merge branch 'dev'
zzyueb Feb 11, 2024
8e77c7b
fix: html webpack plugin config
zzyueb Feb 11, 2024
2cc75e1
Merge branch 'dev'
zzyueb Feb 11, 2024
e07532a
perf: add 'mode'
zzyueb Feb 12, 2024
efc2ad2
Merge branch 'dev'
zzyueb Feb 12, 2024
9fa375a
feat: add CssMinimizerPlugin
zzyueb Feb 13, 2024
0478e42
Merge branch 'dev'
zzyueb Feb 13, 2024
b668b27
refactor: use webpack chain and change to typescript
zzyueb Feb 14, 2024
b26d1e6
Merge branch 'dev'
zzyueb Feb 14, 2024
b9bfe1f
perf: remove redundant comments
zzyueb Feb 14, 2024
c063f5c
Merge branch 'dev'
zzyueb Feb 14, 2024
6793c48
perf: remove redundant comments and packages
zzyueb Feb 14, 2024
8ceb7b2
Merge branch 'dev'
zzyueb Feb 14, 2024
4178393
perf: remove redundant comments and packages
zzyueb Feb 14, 2024
cecff1c
Merge branch 'dev'
zzyueb Feb 14, 2024
db8cd79
feat: add alias '#' as './types'
zzyueb Feb 14, 2024
dd7cffa
Merge branch 'dev'
zzyueb Feb 14, 2024
e21e167
feat: add exportLocalsConvention
zzyueb Feb 14, 2024
55def9d
feat: add ts-loader and thread-loader
zzyueb Feb 14, 2024
fd80704
feat: add dotenv
zzyueb Feb 14, 2024
30f5ac9
fix: take dotenv as conditional
zzyueb Feb 15, 2024
4adb9e8
fix: take dotenv as conditional and merge two compose functions to one
zzyueb Feb 15, 2024
9361141
Merge branch 'dev'
zzyueb Feb 15, 2024
2675a05
feat: add version checker
zzyueb Feb 15, 2024
61426c9
Merge branch 'dev'
zzyueb Feb 15, 2024
4ed7c0c
feat: add version checker
zzyueb Feb 15, 2024
c13cd04
Merge branch 'dev'
zzyueb Feb 15, 2024
7effedf
fix: condition fix
zzyueb Feb 15, 2024
218b50d
Merge branch 'dev'
zzyueb Feb 15, 2024
4362f0d
fix: condition fix and ts checker doc
zzyueb Feb 15, 2024
cd4c1dc
Merge branch 'dev'
zzyueb Feb 15, 2024
22dde49
feat: reuse of webpack-chain
zzyueb Feb 16, 2024
d17eaae
Merge branch 'dev'
zzyueb Feb 16, 2024
d977155
feat: add generator
zzyueb Feb 17, 2024
5096da6
Merge branch 'dev'
zzyueb Feb 17, 2024
7093691
fix: update README
zzyueb Feb 18, 2024
d77a231
Merge branch 'dev'
zzyueb Feb 18, 2024
a90d8a0
fix: tap
zzyueb Feb 21, 2024
6f81845
Merge branch 'dev'
zzyueb Feb 21, 2024
42fa2bb
feat: add esbuild when dev
zzyueb Feb 23, 2024
34896f5
Merge branch 'dev'
zzyueb Feb 23, 2024
0a64c86
fix: css source map
zzyueb Feb 23, 2024
a876176
Merge branch 'dev'
zzyueb Feb 23, 2024
c24b081
fix: source map fixed
zzyueb Feb 23, 2024
d9ca354
fix: add less options
zzyueb Feb 23, 2024
dc603c3
fix: loadCss oneOf name
zzyueb Feb 23, 2024
aed3c09
fix: toggle include and exclude to user
zzyueb Feb 23, 2024
3191553
fix: close happyPackMode when dev
zzyueb Feb 23, 2024
d244da9
feat: add resolve-url-loader
zzyueb Jun 2, 2024
cd0de41
feat: Add shims-img
zzyueb Jun 2, 2024
daacbf0
fix: delete unused file
zzyueb Jun 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

19 changes: 19 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
corejs: '3.35',
},
],
[
'@babel/preset-react',
{
runtime: 'automatic',
},
],
'@babel/preset-typescript',
],
plugins: ['@babel/plugin-syntax-dynamic-import'],
};
33 changes: 33 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
charset = utf-8

# 4 space indentation
[*.py]
indent_style = space
indent_size = 4

# Tab indentation (no size specified)
[Makefile]
indent_style = space

# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 4

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml,tsconfig.json}]
indent_style = space
indent_size = 4
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package.json
package-lock.json
tsconfig.json
67 changes: 67 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module.exports = {
env: {
browser: true,
es2022: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:react/all',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
overrides: [],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'prettier', 'react', 'react-hooks'],
rules: {
indent: [
'error',
4,
{
SwitchCase: 1,
},
],
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single', { avoidEscape: true }],
semi: ['error', 'always'],
'prettier/prettier': [
'error',
{},
{
usePrettierrc: true,
},
],
'@typescript-eslint/no-var-requires': 'off',
'react/jsx-filename-extension': [
'error',
{
extensions: ['.js', '.jsx', '.tsx'],
},
],
'react/jsx-no-literals': 'off',
'react/jsx-one-expression-per-line': ['error', { allow: 'single-child' }],
'react-hooks/exhaustive-deps': 'off',
'react/jsx-no-bind': [
1,
{
allowArrowFunctions: true,
allowFunctions: true,
allowBind: true,
},
],
'react/function-component-definition': [
2,
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function',
},
],
'react/prop-types': 'off',
},
};
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ typings/
.yarn-integrity

# dotenv environment variables file
.env
.env

# for MacOS
.DS_Store

dist/
3 changes: 3 additions & 0 deletions .postcssrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
plugins: [require('autoprefixer'), require('postcss-preset-env')],
};
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package.json
package-lock.json
tsconfig.json
9 changes: 9 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
printWidth: 120
tabWidth: 4
semi: true
singleQuote: true
trailingComma: 'es5'
bracketSameLine: false
arrowParens: 'avoid'
singleAttributePerLine: true
proseWrap: never
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
},
"editor.formatOnSave": true,
"eslint.enable": true,
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Webpack React New

This is a basic template with `React 18 + TypeScript + Webpack 5`. You can use this repository as your project template.

## Installation

Please note:

* The Node.js version must be `>= 14`.
* It's recommended to use the LTS version.

```sh
# Clone this template
$ npx degit https://github.com/My-Project-Template/webpack-react-new.git YOUR_PROJECT_DIRECTORY

# Using yarn
$ yarn dlx degit https://github.com/My-Project-Template/webpack-react-new.git YOUR_PROJECT_DIRECTORY

# Using pnpm
$ pnpm dlx degit https://github.com/My-Project-Template/webpack-react-new.git YOUR_PROJECT_DIRECTORY

# Navigate to your project directory
$ cd YOUR_PROJECT_DIRECTORY
$ rm -rf package-lock.json

# If you're using npm
$ npm i
$ npm run dev

# If you're using yarn
$ yarn
$ yarn dev

# Or, if you're using pnpm, the following line is crucial!
$ pnpm up
$ pnpm run dev
```
36 changes: 36 additions & 0 deletions confs/CheckNodejsVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { versions, release } from 'process';

/** the options */
type Opts = Partial<{
/** @description the lowest version */
lowestVersion: number;
/** @description the highest version */
highestVersion: number;
/** @description is limited to LTS */
isTakingLTS: boolean;
}>;

/** @description Check node.js version before running programme. */
export const checkNodejsVersion = (opts: Opts = {}) => {
const { lowestVersion = 14, highestVersion, isTakingLTS = true } = opts || {};

const [greatestVersion] = versions.node.split('.').map(v => +v);

// Check the greatest version is equal to or more than the lowest version.
if (lowestVersion && greatestVersion < lowestVersion) {
throw new Error(`The Nodejs version should be >= ${lowestVersion}`);
}

// Check the greatest version is equal to or less than the highest version.
if (highestVersion && greatestVersion > highestVersion) {
throw new Error(`The Nodejs version should be <= ${highestVersion}`);
}

// Check whether is LTS version or not.
const { lts } = release;
if (isTakingLTS && (greatestVersion % 2 === 1 || !lts)) {
throw new Error('Must use LTS version!');
}

console.log('The Nodejs version is valid!');
};
3 changes: 3 additions & 0 deletions confs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { createBasicConfig } from './webpack';
export { checkNodejsVersion } from './CheckNodejsVersion';
export type { SelfDefineOptions } from './webpack';
Loading