Skip to content

Commit 82c4b77

Browse files
committed
🎉 new webpack plugin
0 parents  commit 82c4b77

39 files changed

+9880
-0
lines changed

.circleci/config.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
# specify the version you desire here
6+
- image: circleci/node:latest-browsers
7+
environment:
8+
NPM_CONFIG_LOGLEVEL: error
9+
JOBS: max # https://gist.github.com/ralphtheninja/f7c45bdee00784b41fed
10+
working_directory: ~/micro-app-plugin-webpack-adapter
11+
branches:
12+
ignore:
13+
- docs
14+
- gh-pages
15+
16+
steps:
17+
- checkout
18+
- restore_cache:
19+
key: micro-app-plugin-webpack-adapter-{{ .Branch }}-{{ checksum "yarn.lock" }}
20+
- run: yarn --network-timeout 600000
21+
- save_cache:
22+
key: micro-app-plugin-webpack-adapter-{{ .Branch }}-{{ checksum "yarn.lock" }}
23+
paths:
24+
- ./node_modules
25+
- run: yarn run test --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
26+

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
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

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
coverage
3+
.vscode
4+
.circleci

.eslintrc.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
node: true
6+
},
7+
extends: [
8+
"eslint-config-2o3t"
9+
],
10+
parserOptions: {
11+
parser: "babel-eslint"
12+
},
13+
}

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @zyao89

.gitignore

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Node template
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
10+
# Runtime data
11+
pids
12+
*.pid
13+
*.seed
14+
*.pid.lock
15+
16+
# Directory for instrumented libs generated by jscoverage/JSCover
17+
lib-cov
18+
19+
# Coverage directory used by tools like istanbul
20+
coverage
21+
22+
# nyc test coverage
23+
.nyc_output
24+
25+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26+
.grunt
27+
28+
# Bower dependency directory (https://bower.io/)
29+
bower_components
30+
31+
# node-waf configuration
32+
.lock-wscript
33+
34+
# Compiled binary addons (https://nodejs.org/api/addons.html)
35+
build/Release
36+
37+
# Dependency directories
38+
node_modules/
39+
jspm_packages/
40+
41+
# TypeScript v1 declaration files
42+
typings/
43+
44+
# Optional npm cache directory
45+
.npm
46+
47+
# Optional eslint cache
48+
.eslintcache
49+
50+
# Optional REPL history
51+
.node_repl_history
52+
53+
# Output of 'npm pack'
54+
*.tgz
55+
56+
# Yarn Integrity file
57+
.yarn-integrity
58+
59+
# dotenv environment variables file
60+
.env
61+
62+
# parcel-bundler cache (https://parceljs.org/)
63+
.cache
64+
65+
# next.js build output
66+
.next
67+
68+
# nuxt.js build output
69+
.nuxt
70+
71+
# Nuxt generate
72+
dist
73+
74+
# vuepress build output
75+
.vuepress/dist
76+
77+
# Serverless directories
78+
.serverless
79+
80+
# IDE
81+
.idea
82+
83+
.vscode
84+
*.suo
85+
*.ntvs*
86+
*.njsproj
87+
*.sln
88+
*.sw*

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019-present, Zyao89
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Micro APP Plugin - Webpack
2+
3+
[Plugin] webpack plugin.
4+
5+
基于webpack多入口的多仓库业务模块开发的插件应用框架核心库.
6+
7+
[![Coverage Status][Coverage-img]][Coverage-url]
8+
[![CircleCI][CircleCI-img]][CircleCI-url]
9+
[![NPM Version][npm-img]][npm-url]
10+
[![NPM Download][download-img]][download-url]
11+
12+
[Coverage-img]: https://coveralls.io/repos/github/MicroAppJS/MicroApp-Plugin-Webpack/badge.svg?branch=master
13+
[Coverage-url]: https://coveralls.io/github/MicroAppJS/MicroApp-Plugin-Webpack?branch=master
14+
[CircleCI-img]: https://circleci.com/gh/MicroAppJS/MicroApp-Plugin-Webpack/tree/master.svg?style=svg
15+
[CircleCI-url]: https://circleci.com/gh/MicroAppJS/MicroApp-Plugin-Webpack/tree/master
16+
[npm-img]: https://img.shields.io/npm/v/@micro-app/plugin-webpack.svg?style=flat-square
17+
[npm-url]: https://npmjs.org/package/@micro-app/plugin-webpack
18+
[download-img]: https://img.shields.io/npm/dm/@micro-app/plugin-webpack.svg?style=flat-square
19+
[download-url]: https://npmjs.org/package/@micro-app/plugin-webpack
20+
21+
## Install
22+
23+
```sh
24+
yarn add @micro-app/plugin-webpack
25+
```
26+
27+
or
28+
29+
```sh
30+
npm install -S @micro-app/plugin-webpack
31+
```
32+
33+
## Usage
34+
35+
### 在项目 `根目录``micro-app.config.js` 文件中配置
36+
37+
```js
38+
module.exports = {
39+
// ...
40+
41+
plugins: [ // 自定义插件
42+
['@micro-app/plugin-webpack', {
43+
// 一些插件配置项
44+
// ReplaceFileNotExists: {
45+
// debug: false, // 开启log
46+
// warnHint: 'Not Found',
47+
// loader: '', // 路径
48+
// resource: '', // 路径
49+
// test: /^@micros\//i, // 匹配规则
50+
// },
51+
// SpeedMeasurePlugin: {
52+
// disabled: true,
53+
// },
54+
// HappyPack: {
55+
// disabled: true,
56+
// },
57+
}],
58+
],
59+
};
60+
```
61+
62+
### Build
63+
64+
```sh
65+
npx micro-app build
66+
```
67+
68+
or
69+
70+
```sh
71+
npx micro-app-build
72+
```
73+
74+
75+
### 内置部分插件提供的 api 方法补充
76+
77+
可通过如下命令进行动态查看
78+
79+
```js
80+
npx micro-app show methods
81+
```
82+
83+
以提供的方法如下, `System Build-in` 为内置方法
84+
85+
```js
86+
╰─➤ npx micro-app show methods
87+
Plugin Methods:
88+
* beforeMergeWebpackConfig ( 合并 webpack 配置之前事件 )
89+
* afterMergeWebpackConfig ( 合并 webpack 配置之后事件 )
90+
* modifyChainWebpcakConfig ( 合并之后提供 webpack-chain 进行再次修改事件 )
91+
* onChainWebpcakConfig ( 修改之后提供 webpack-chain 进行查看事件 )
92+
* modifyWebpackConfig ( 合并之后提供 webpack config 进行再次修改事件 )
93+
* onBuildSuccess ( 构建成功时事件 )
94+
* onBuildFail ( 构建失败时事件 )
95+
* beforeBuild ( 开始构建前事件 )
96+
* afterBuild ( 构建结束后事件 )
97+
```

bin/micro-app-build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
5+
6+
const yParser = require('yargs-parser');
7+
const argv = yParser(process.argv.slice(2));
8+
const { service } = require('@micro-app/cli');
9+
10+
service.run('build', argv);

micro-app.config.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
'use strict';
2+
3+
module.exports = {
4+
name: '@micro-app/demo',
5+
description: '',
6+
version: '0.0.1',
7+
type: '', // types 类型
8+
webpack: { // webpack 配置 (只有自己使用)
9+
// output: {
10+
// path: require('path').resolve(__dirname, 'public'),
11+
// publicPath: '/public/',
12+
// },
13+
},
14+
15+
entry: {
16+
main: './test/index.js',
17+
},
18+
19+
htmls: [
20+
{
21+
template: './test/index.js',
22+
},
23+
],
24+
25+
// staticPath: '',
26+
27+
// dlls: [
28+
// {
29+
// context: __dirname,
30+
// },
31+
// ],
32+
33+
alias: { // 前端
34+
api: 'abc',
35+
config: {
36+
link: 'abc',
37+
description: '配置',
38+
},
39+
service: {
40+
link: 'abc',
41+
description: '接口',
42+
type: 'server',
43+
},
44+
},
45+
46+
strict: true,
47+
48+
// micros: [ 'test' ], // 被注册的容器
49+
// micros$$test: { // 单独配置
50+
// disabled: true, // 禁用入口
51+
// link: '', // 本地路径, 进行本地开发使用的软链接.
52+
// },
53+
54+
// 服务配置
55+
server: {
56+
entry: '', // 服务端入口
57+
port: 8088, // 服务端口号
58+
options: {
59+
// 服务端回调参数
60+
},
61+
},
62+
63+
plugins: [
64+
{
65+
id: 'test',
66+
link: __dirname + '/src/index.js',
67+
},
68+
],
69+
};

0 commit comments

Comments
 (0)