Skip to content

Commit c23d62b

Browse files
powerfulyangpowerfulyang
powerfulyang
authored and
powerfulyang
committed
feat: swc starter and d3-tutorial
1 parent c3d6f6e commit c23d62b

21 files changed

+8729
-0
lines changed

.commitlintrc.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
};

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[Makefile]
16+
indent_style = tab

.eslintrc.cjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { eslint } = require('@powerfulyang/lint');
2+
3+
module.exports = {
4+
...eslint,
5+
rules: {
6+
...eslint.rules,
7+
'import/no-extraneous-dependencies': [
8+
'error',
9+
{
10+
devDependencies: [
11+
'.*rc.{js,cjs,mjs,ts,cts,mts}',
12+
'**/*.config.{js,cjs,mjs,ts,cts,mts}',
13+
'**/*.spec.{ts,tsx}',
14+
'**/webpack.*.js',
15+
],
16+
},
17+
],
18+
},
19+
};

.gitattributes

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Denote all files that are truly binary and should not be modified.
5+
*.png binary
6+
*.jpg binary
7+
*.gif binary
8+
*.ico binary
9+
10+
# Declare files that will always have LF line endings on checkout.
11+
*.tsx text eol=lf
12+
*.ts text eol=lf
13+
*.mts text eol=lf
14+
*.cts text eol=lf
15+
*.js text eol=lf
16+
*.mjs text eol=lf
17+
*.cjs text eol=lf
18+
*.jsx text eol=lf
19+
*.md text eol=lf
20+
*.scss text eol=lf
21+
*.less text eol=lf
22+
*.css text eol=lf
23+
*.json text eol=lf
24+
*.yml text eol=lf
25+
*.yaml text eol=lf
26+
*.xml text eol=lf
27+
*.html text eol=lf
28+
*.htm text eol=lf
29+
*.sh text eol=lf
30+
*.bat text eol=lf
31+
*.cmd text eol=lf
32+
*.ps1 text eol=lf

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Node CI
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
node_version: [lts/*]
11+
os: [ubuntu-latest]
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: pnpm/action-setup@v2
15+
with:
16+
version: latest
17+
- name: Use Node.js ${{ matrix.node_version }}
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: ${{ matrix.node_version }}
21+
cache: 'pnpm'
22+
cache-dependency-path: 'pnpm-lock.yaml'
23+
- run: pnpm install --frozen-lockfile
24+
- run: pnpm run build
25+
- name: Deploy
26+
uses: peaceiris/actions-gh-pages@v3
27+
with:
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
publish_dir: ./dist

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ dist
102102

103103
# TernJS port file
104104
.tern-port
105+
106+
.idea

.lintstagedrc.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
'**/*.{ts,tsx,json,js,mjs,mts,cjs,cts,jsx,md}': ['prettier --write'],
3+
'**/*.{ts,tsx,js,mjs,mts,cjs,cts,jsx}': ['eslint --fix'],
4+
'**/*.scss': ['stylelint --fix'],
5+
};

.npmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
auto-install-peers=true
2+
enable-pre-post-scripts=true
3+
shamefully-hoist=true

.prettierrc.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const { prettier } = require('@powerfulyang/lint');
2+
3+
module.exports = {
4+
...prettier,
5+
};

.stylelintrc.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const { stylelint } = require('@powerfulyang/lint');
2+
3+
module.exports = {
4+
...stylelint,
5+
};

.swcrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"minify": true,
3+
"test": ".*.tsx$",
4+
"jsc": {
5+
"parser": {
6+
"syntax": "typescript",
7+
"tsx": true,
8+
"decorators": true,
9+
"dynamicImport": true
10+
}
11+
}
12+
}

config/webpack.base.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const path = require('path');
2+
const HTMLWebpackPlugin = require('html-webpack-plugin');
3+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
4+
const webpack = require('webpack');
5+
6+
module.exports = {
7+
entry: './src/index.tsx',
8+
experiments: {
9+
topLevelAwait: true,
10+
},
11+
module: {
12+
rules: [
13+
{
14+
test: /\.tsx$/,
15+
exclude: /node_modules/,
16+
loader: 'swc-loader',
17+
},
18+
{
19+
test: /\.html$/,
20+
loader: 'html-loader',
21+
options: { minimize: true },
22+
},
23+
{
24+
test: /\.scss/i,
25+
use: ['style-loader', 'css-loader', 'sass-loader'],
26+
},
27+
{
28+
test: /\.css$/i,
29+
use: ['style-loader', 'css-loader'],
30+
},
31+
],
32+
},
33+
resolve: {
34+
extensions: ['.tsx', '.js'],
35+
},
36+
output: {
37+
filename: 'bundle.js',
38+
path: path.resolve(__dirname, '../dist'),
39+
},
40+
plugins: [
41+
new HTMLWebpackPlugin({
42+
filename: 'index.html',
43+
template: path.join(__dirname, '../static/index.html'),
44+
}),
45+
new CleanWebpackPlugin({
46+
cleanOnceBeforeBuildPatterns: [path.join(__dirname, '../dist')],
47+
}),
48+
new webpack.DefinePlugin({
49+
'process.env.BASE_URL': JSON.stringify(process.env.BASE_URL || ''),
50+
}),
51+
],
52+
};

config/webpack.dev.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const path = require('path');
2+
const { merge } = require('webpack-merge');
3+
const common = require('./webpack.base');
4+
5+
module.exports = merge(common, {
6+
mode: 'development',
7+
devtool: 'inline-source-map',
8+
devServer: {
9+
liveReload: true,
10+
open: true,
11+
port: 9000,
12+
historyApiFallback: true,
13+
static: {
14+
directory: path.join(__dirname, '../dist'),
15+
},
16+
proxy: {
17+
'/api': {
18+
target: 'https://api.powerfulyang.com',
19+
changeOrigin: true,
20+
},
21+
},
22+
},
23+
});

config/webpack.prod.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const { merge } = require('webpack-merge');
2+
const common = require('./webpack.base');
3+
4+
module.exports = merge(common, {
5+
mode: 'production',
6+
});

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "d3-tutorial",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"dev": "webpack serve --config ./config/webpack.dev.js",
8+
"build": "cross-env BASE_URL=https://api.powerfulyang.com webpack --config ./config/webpack.prod.js"
9+
},
10+
"keywords": [
11+
"d3-tutorial"
12+
],
13+
"author": "powerfulyang",
14+
"license": "MIT",
15+
"devDependencies": {
16+
"@powerfulyang/lint": "3.1.3",
17+
"webpack": "latest",
18+
"webpack-cli": "latest",
19+
"webpack-dev-server": "latest",
20+
"webpack-merge": "latest",
21+
"typescript": "latest",
22+
"@types/d3": "latest",
23+
"html-webpack-plugin": "latest",
24+
"clean-webpack-plugin": "latest",
25+
"swc-loader": "latest",
26+
"html-loader": "latest"
27+
},
28+
"dependencies": {
29+
"d3": "latest"
30+
}
31+
}

0 commit comments

Comments
 (0)