Skip to content

Commit

Permalink
feat: inital commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dpyzo0o committed Dec 16, 2019
0 parents commit a9cfe24
Show file tree
Hide file tree
Showing 33 changed files with 17,062 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
18 changes: 18 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["taro"],
"rules": {
"@typescript-eslint/no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
"no-unused-vars": ["off"],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }],
"react/sort-comp": 0
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"useJSXTextNode": true,
"project": "./tsconfig.json"
}
}
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dist/
deploy_versions/
.temp/
.rn_temp/
node_modules/
.DS_Store

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"jsxSingleQuote": true,
"printWidth": 100,
"trailingComma": "es5"
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.formatOnSave": true,
"eslint.validate": [
{ "language": "typescript", "autoFix": true },
{ "language": "typescriptreact", "autoFix": true }
]
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Taro-Toolkit

Taro + Redux + Typescript 快速开发模版
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
8 changes: 8 additions & 0 deletions config/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
env: {
NODE_ENV: '"development"',
},
defineConstants: {},
weapp: {},
h5: {},
};
114 changes: 114 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
const path = require('path');

// NOTE 在 sass 中通过别名(@ 或 ~)引用需要指定路径
const sassImporter = function(url) {
if (url[0] === '~' && url[1] !== '/') {
return {
file: path.resolve(__dirname, '..', 'node_modules', url.substr(1)),
};
}

const reg = /^@styles\/(.*)/;
return {
file: reg.test(url) ? path.resolve(__dirname, '..', 'src/styles', url.match(reg)[1]) : url,
};
};

const config = {
projectName: 'with-redux-toolkit',
date: '2019-12-5',
designWidth: 750,
deviceRatio: {
'640': 2.34 / 2,
'750': 1,
'828': 1.81 / 2,
},
sourceRoot: 'src',
outputRoot: 'dist',
plugins: {
babel: {
sourceMap: true,
presets: [
[
'env',
{
modules: false,
},
],
],
plugins: [
'transform-decorators-legacy',
'transform-class-properties',
'transform-object-rest-spread',
],
},
sass: {
importer: sassImporter,
},
},
defineConstants: {},
alias: {
'~': path.resolve(__dirname, '..', 'src'),
},
copy: {
patterns: [],
options: {},
},
weapp: {
module: {
postcss: {
autoprefixer: {
enable: true,
config: {
browsers: ['last 3 versions', 'Android >= 4.1', 'ios >= 8'],
},
},
pxtransform: {
enable: true,
config: {},
},
url: {
enable: true,
config: {
limit: 10240, // 设定转换尺寸上限
},
},
cssModules: {
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]',
},
},
},
},
},
h5: {
publicPath: '/',
staticDirectory: 'static',
module: {
postcss: {
autoprefixer: {
enable: true,
config: {
browsers: ['last 3 versions', 'Android >= 4.1', 'ios >= 8'],
},
},
cssModules: {
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: 'module', // 转换模式,取值为 global/module
generateScopedName: '[name]__[local]___[hash:base64:5]',
},
},
},
},
},
};

module.exports = function(merge) {
if (process.env.NODE_ENV === 'development') {
return merge({}, config, require('./dev'));
}
return merge({}, config, require('./prod'));
};
17 changes: 17 additions & 0 deletions config/prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
env: {
NODE_ENV: '"production"',
},
defineConstants: {},
weapp: {},
h5: {
/**
* 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
* 参考代码如下:
* webpackChain (chain) {
* chain.plugin('analyzer')
* .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
* }
*/
},
};
18 changes: 18 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
declare module "*.png";
declare module "*.gif";
declare module "*.jpg";
declare module "*.jpeg";
declare module "*.svg";
declare module "*.css";
declare module "*.less";
declare module "*.scss";
declare module "*.sass";
declare module "*.styl";

// @ts-ignore
declare const process: {
env: {
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq';
[key: string]: any;
}
}
Loading

0 comments on commit a9cfe24

Please sign in to comment.