Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Nov 27, 2017
0 parents commit c8c7c70
Show file tree
Hide file tree
Showing 68 changed files with 2,546 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .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 = true

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
lib/
dist/
template/
fixtures/
48 changes: 48 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"parser": "babel-eslint",
"extends": "airbnb",
"env": {
"mocha": true
},
"rules": {
"jsx-a11y/href-no-hash": [0],
"generator-star-spacing": [0],
"consistent-return": [0],
"react/react-in-jsx-scope": [0],
"react/forbid-prop-types": [0],
"react/jsx-filename-extension": [1, { "extensions": [".js"] }],
"global-require": [1],
"import/prefer-default-export": [0],
"react/jsx-no-bind": [0],
"react/prop-types": [0],
"react/prefer-stateless-function": [0],
"no-else-return": [0],
"no-restricted-syntax": [0],
"import/no-extraneous-dependencies": [0],
"no-use-before-define": [0],
"jsx-a11y/no-static-element-interactions": [0],
"no-nested-ternary": [0],
"arrow-body-style": [0],
"import/extensions": [0],
"no-bitwise": [0],
"no-cond-assign": [0],
"import/no-unresolved": [0],
"require-yield": [1],
"no-param-reassign": [0],
"no-shadow": [0],
"no-underscore-dangle": [0],
"spaced-comment": [0],
"indent": [0],
"quotes": [0],
"func-names": [0],
"arrow-parens": [0],
"space-before-function-paren": [0],
"no-useless-escape": [0],
"object-curly-newline": [0]
},
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
}
}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.DS_Store
tmp
/node_modules
/packages/*/node_modules
/boilerplates/*/node_modules
/boilerplates/*/www
/boilerplates/*/_dist
/boilerplates/*/_package
lib
dist
coverage
.nyc_output
npm-debug.log*
lerna-debug.log
.changelog
.koi
/boilerplates/*/node_modules
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/fixtures/**/*.js
**/template/*.js
**/bin/*.js
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# umi

> under development.
8 changes: 8 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"lerna": "2.0.0",
"packages": [
"packages/*"
],
"npmClient": "npm",
"version": "independent"
}
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"private": true,
"scripts": {
"build": "lerna exec --bail --parallel -- npm run build --",
"debug": "lerna run debug",
"lint": "eslint --ext .js packages",
"precommit": "lint-staged",
"publish": "./scripts/publish.js"
},
"lint-staged": {
"*.js": [
"prettier --trailing-comma all --single-quote --write",
"git add"
]
},
"devDependencies": {
"babel-eslint": "^8.0.2",
"eslint": "^4.10.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.4.0",
"expect": "^1.20.2",
"husky": "^0.14.3",
"lerna": "^2.0.0",
"lint-staged": "^4.0.4",
"prettier": "^1.8.1",
"ruban": "^0.2.1",
"shelljs": "^0.7.8"
}
}
43 changes: 43 additions & 0 deletions packages/af-webpack/Configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Configuration

## How to config

Config via `.webpackrc`, e.g.

```js
{
"alias": { "react": "preact-compat" }
}
```

If you like to write config in JavaScript, config in `.webpackrc.js`, e.g.

```js
export default {
alias: {
react: 'preact-compat',
},
}
```

## Options

| | Default Value | Notes |
| :--- | :--- | :--- |
| entry | null | |
| browsers | [ '>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9' ] | |
| theme | {} | |
| babel | | |
| define | {} | |
| outputPath | null | |
| publicPath | undefined | |
| commons | [] | |
| hash | false | |
| externals | {} | |
| copy | [] | |
| enableCSSModules | false | |
| extraBabelIncludes | [] | |
| extraResolveExtensions | [] | |
| extraPostCSSPlugins | [] | |
| ignoreMomentLocale | false | |
| extraResolveModules | [] | |
85 changes: 85 additions & 0 deletions packages/af-webpack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# af-webpack

Unique webpack wrapper for ant financial (af).

## Why af-webpack ?

TODO

## CLIs based on af-webpack

* umi
* [roadhog@2](https://github.com/sorrycc/roadhog/tree/2.0)

## Configuration

See [./Configuration.md](./Configuration.md).

## API

### af-webpack/getConfig

Get webpack config with opts.

```js
const webpackConfig = getConfig(opts);
// use webpackConfig to dev or build
```

### af-webpack/dev

Run webpack-dev-server more gracefully with [react-dev-utils](https://github.com/facebookincubator/create-react-app/tree/master/packages/react-dev-utils).

```js
dev({
webpackConfig,
appName,
extraMiddlewares,
beforeServer,
});
```

webpackConfig is required, other optional.

Options:

* `webpackConfig`: the webpack config
* `appName`: the default is "Your Project", text to show after dev server is started
* `extraMiddlewares`: extra middlewares for webpack-dev-server, based on express
* `beforeServer`: the function to execute before dev server is started

### af-webpack/build

Run webpack compilation.

```js
build({
webpackConfig,
success,
});
```

webpackConfig is required, other optional.

Options:

* `webpackConfig`: the webpack config
* `success`: the function to execute after build is done successfully

### af-webpack/react-dev-utils

The APIs related to react-dev-utils.

* webpackHotDevClientPath:the real path of webpackHotDevClient

### af-webpack/webpack

The webpack, useful to register extra webpack plugins.

### af-webpack/registerBabel

Register babel for extra files.

## LICENSE

MIT
1 change: 1 addition & 0 deletions packages/af-webpack/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/build');
1 change: 1 addition & 0 deletions packages/af-webpack/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/dev');
1 change: 1 addition & 0 deletions packages/af-webpack/getConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/getConfig');
81 changes: 81 additions & 0 deletions packages/af-webpack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"name": "af-webpack",
"version": "0.9.1",
"dependencies": {
"@babel/core": "7.0.0-beta.31",
"@babel/plugin-transform-modules-commonjs": "7.0.0-beta.31",
"@babel/register": "7.0.0-beta.31",
"@babel/runtime": "7.0.0-beta.31",
"assert": "^1.4.1",
"autoprefixer": "^7.1.4",
"babel-eslint": "^8.0.1",
"babel-loader": "^8.0.0-beta.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-af-react": "^0.6.0",
"case-sensitive-paths-webpack-plugin": "^2.1.1",
"chalk": "^2.1.0",
"copy-webpack-plugin": "^4.2.0",
"css-loader": "^0.28.7",
"debug": "^3.1.0",
"detect-port": "^1.2.1",
"eslint": "^4.7.1",
"eslint-config-af-react": "^0.4.0",
"eslint-loader": "^1.9.0",
"eslint-plugin-flowtype": "^2.34.1",
"eslint-plugin-import": "^2.6.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.1.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.2",
"inquirer": "^3.3.0",
"is-plain-object": "^2.0.4",
"is-root": "^1.0.0",
"less": "^2.7.2",
"less-loader": "^4.0.5",
"postcss": "^6.0.11",
"postcss-flexbugs-fixes": "^3.2.0",
"postcss-loader": "^2.0.6",
"react-dev-utils": "^4.0.1",
"react-error-overlay": "^3.0.0",
"resolve": "^1.5.0",
"sockjs-client": "1.1.4",
"strip-ansi": "3.0.1",
"style-loader": "^0.18.2",
"system-bell-webpack-plugin": "^1.0.0",
"url-loader": "^0.6.2",
"webpack": "^3.5.6",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.4"
},
"repository": {
"type": "git",
"url": "https://github.com/umijs/umi/tree/master/packages/af-webpack"
},
"homepage": "https://github.com/umijs/umi/tree/master/packages/af-webpack",
"authors": [
"chencheng <[email protected]> (https://github.com/sorrycc)"
],
"bugs": {
"url": "https://github.com/umijs/umi/issues"
},
"scripts": {
"build": "NODE_TARGET=1 ruban build",
"test": "ruban test --timeout 200000",
"debug": "ruban debug --timeout 200000",
"coveralls": "ruban coveralls"
},
"devDependencies": {
"glob": "^7.1.2"
},
"files": [
"lib",
"src",
"build.js",
"dev.js",
"getConfig.js",
"react-dev-utils.js",
"registerBabel.js",
"webpack.js"
],
"license": "MIT"
}
1 change: 1 addition & 0 deletions packages/af-webpack/react-dev-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/reactDevUtils');
1 change: 1 addition & 0 deletions packages/af-webpack/registerBabel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/registerBabel');
30 changes: 30 additions & 0 deletions packages/af-webpack/src/applyWebpackConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { existsSync } from 'fs';
import { resolve } from 'path';
import chalk from 'chalk';
import webpack from 'webpack';

export function warnIfExists() {
const filePath = resolve('webpack.config.js');
if (existsSync(filePath)) {
console.log(
chalk.yellow(
`⚠️ ⚠️ ⚠️ It\\'s not recommended to use ${chalk.bold(
'webpack.config.js',
)}, since it\\'s major or minor version upgrades may result in incompatibility. If you insist on doing so, please be careful of the compatibility after upgrading.`,
),
);
console.log();
}
}

export function applyWebpackConfig(config) {
const filePath = resolve('webpack.config.js');
if (existsSync(filePath)) {
return require(filePath)(config, {
// eslint-disable-line
webpack,
});
} else {
return config;
}
}
Loading

0 comments on commit c8c7c70

Please sign in to comment.