Skip to content

Commit

Permalink
feat: 初始化 doc
Browse files Browse the repository at this point in the history
  • Loading branch information
imsunhao committed Jun 20, 2019
1 parent 5ab5103 commit cbb386e
Show file tree
Hide file tree
Showing 48 changed files with 11,834 additions and 3 deletions.
36 changes: 36 additions & 0 deletions doc/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"targets": {
"chrome": "58",
"ie": "9"
}
}
]
],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"helpers": false
}
],
"@babel/plugin-transform-modules-commonjs",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-syntax-dynamic-import",
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
]
],
"env": {
"test": {
"sourceMap": true
}
}
}
16 changes: 16 additions & 0 deletions doc/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# http://editorconfig.org
root = true

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

[*.html]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
68 changes: 68 additions & 0 deletions doc/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
var rules = {
"no-unused-vars": [
"warn",
{
"varsIgnorePattern": "^__",
"argsIgnorePattern": "^__"
}
],
"no-console": [
"off"
],
"prefer-const": [
"warn"
],
}

var plugins = [
"html",
"vue"
]

module.exports = {
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"legacyDecorators": true,
"experimentalObjectRestSpread": true
}
},
"extends": [
"eslint:recommended",
],
"rules": rules,
"plugins": plugins,
"env": {
"es6": true,
"node": true,
"browser": true,
},
"globals": {
"window": false,
"process": false,
"document": false,
"require": false,
"console": false,
"module": false,
"Blob": false,
"HTMLCollection": false,
"Element": false,
"NodeList": false,
"Worker": false,
"history": false,
"Image": false,
"ImageData": false,
"Audio": false,
"URL": false,
"setInterval": false,
"clearInterval": false,
"location": false,
"localStorage": false,
"setTimeout": false,
"__dirname": false,
"Buffer": false,
"__webpack_public_path__": true
}
}
8 changes: 8 additions & 0 deletions doc/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.jpg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.svg filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.eot filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.woff filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
8 changes: 8 additions & 0 deletions doc/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"printWidth": 120,
"tabWidth": 2,
"singleQuote": true,
"semi": false,
"trailingComma": "all",
"noBracketSpacing": false
}
101 changes: 101 additions & 0 deletions doc/@types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { Store } from 'vuex'

declare namespace Doc {
type DictOf<T> = { [key: string]: T }

/**
* vuex store
* * typescript namespace
*/
namespace Tstore {
/**
* vuex 创建 工具函数
* * typescript namespace
*/
namespace TcreateUtils {
type ActionDescriptor = [any, any]

/**
* 用于声明 Actions Descriptors
*/
type ActionsOfDescriptors<Context, Descriptor extends DictOf<ActionDescriptor>> = {
[K in keyof Descriptor]: (ctx: Context, payload: Descriptor[K][0]) => Descriptor[K][1]
}

/**
* 用于声明 Mutations
*/
type ModuleMutations<State, PayloadTree> = {
[K in keyof PayloadTree]: (state: State, payload: PayloadTree[K]) => any
}
}

/**
* vuex state
*/
interface state {
/**
* 是否 使用 移动设备 访问
* * 来自服务器端
*/
isMobile: boolean

/**
* 初始化 跳转访问 URL
* * 来自服务器端
*/
initialReplaceStateUrl: string
}

/**
* vuex Mutation-Payload-tree
*/
interface MutationPayloads {
/**
* 全局
*/
global: {
SET_IS_MOBILE: boolean
}

/**
* 编辑器
*/
editor: {
SET_HELLO_EDITOR: string
test: undefined
test2?: string
}
}
}

/**
* vue router
*/
namespace Trouter {
/**
* 客户端 获取服务端 异步数据
*/
interface asyncData {
store: Store<Tstore.state>
}

/**
* 页面级别 中间件
* * 根据 server-middlewares path
*/
namespace asyncData {
/**
* path
* * /
*/
interface index extends asyncData {
serverStore: {
hello: string
}
}
}
}
}

export = Doc
11 changes: 11 additions & 0 deletions doc/@types/shims-tsx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Vue, { VNode } from 'vue'

declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any
}
}
}
4 changes: 4 additions & 0 deletions doc/@types/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}
1 change: 1 addition & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @bestminr/build-doc
5 changes: 5 additions & 0 deletions doc/build.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"entry": "./build.config.ts",
"injectContext": "./inject-context.json",
"output": "./dist/build"
}
49 changes: 49 additions & 0 deletions doc/build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { ConfigOptions } from '@bestminr/build'

import { getConfig } from './config'
import getBase from './build/webpack.base.conf.babel'
import getDll from './build/webpack.dll.conf.babel'
import getClient from './build/webpack.client.conf.babel'
import getServer from './build/webpack.server.conf.babel'
import path from 'path'

export default function(inject: ConfigOptions.getOptionsInject): ConfigOptions.options {
const config = getConfig(inject)

const base: any = getBase(config, inject)
const dll: any = getDll(config, inject)
const client: any = getClient(config, inject)
const server: any = getServer(config, inject)

return {
env: ['SERVER_ENV', 'ENV', 'NODE_ENV'],
babelrc: {
presets: [
[
'@babel/preset-env',
{
modules: false,
targets: {
browsers: ['IE >= 11', 'last 2 versions'],
},
},
],
],
},
render: config.render,
statics: config.statics,
proxyTable: config.proxyTable,
extensions: {
entry: {
extensions: inject.resolve('./server/index.js'),
},
path: path.resolve(base.output.path),
},
webpack: {
dll,
base,
client,
server,
},
}
}
32 changes: 32 additions & 0 deletions doc/build/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import path from 'path'
import config from '../config'
import HappyPack from 'happypack'
import webpack from 'webpack'

export function assetsPath(_path) {
return path.posix.join(config.assetsSubDirectory, _path)
}

export function makeHappyPack(id, loaders) {
return new HappyPack({
id: id,
threads: 4,
loaders: loaders
})
}

export const resolve = (p) => path.resolve(__dirname, '..', p)

export function makeDllPlugins(nameArr) {
const plugins = []
nameArr.forEach((name) => {
plugins.push(
new webpack.DllReferencePlugin({
// context: resolve('.'),
// manifest: config.isProd ? require(`../dist/build/dll/${name}.manifest.json`) : require(`../dist/dll/${name}.manifest.json`)
manifest: require(resolve(`${config.assetRoot}/dll/${name}.manifest.json`)),
})
)
})
return plugins
}
24 changes: 24 additions & 0 deletions doc/build/webpack.base.conf.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export default function(config, { resolve }) {
return {
output: {
path: config.assetRoot,
publicPath: config.outputPath,
},
resolve: {
alias: {
public: resolve('public'),
src: resolve('src'),
store$: resolve('src/store/index.ts')
},
},
module: {
rules: [
{
test: /worker\.js$/,
loader: 'worker-loader',
options: { inline: true },
},
],
},
}
}
10 changes: 10 additions & 0 deletions doc/build/webpack.client.conf.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default function(config, { resolve }) {
return {
entry: {
app: ['./src/entry-client.ts'],
},
output: {
globalObject: 'this',
}
}
}
Loading

0 comments on commit cbb386e

Please sign in to comment.