├── .all-contributorsrc
├── .eslintignore
├── .eslintrc
├── .gitattributes
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── docs
├── easywebpack.md
├── images
│ ├── easy-build-size.png
│ ├── easy-egg-react.png
│ ├── easy-egg-vue.png
│ ├── easy-init.png
│ ├── easywebpack.png
│ └── easywebpack.solution.png
├── issue_template.md
└── learn.md
├── lerna.json
├── package.json
├── packages
├── cli
│ ├── easywebpack-cli
│ │ ├── .eslintignore
│ │ ├── .eslintrc
│ │ ├── .gitattributes
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── CHANGELOG.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── README.zh-CN.md
│ │ ├── bin
│ │ │ └── cli.js
│ │ ├── doc
│ │ │ ├── easy-add.png
│ │ │ ├── easy-build-s-cmd.png
│ │ │ ├── easy-init-step-one.png
│ │ │ ├── easy-init-step-two.png
│ │ │ ├── easy-server-cmd.png
│ │ │ ├── easywebpack-logo.png
│ │ │ └── issue_template.md
│ │ ├── index.js
│ │ ├── lib
│ │ │ ├── action.js
│ │ │ ├── babel.js
│ │ │ ├── builder.js
│ │ │ ├── command.js
│ │ │ ├── constant.js
│ │ │ ├── download.js
│ │ │ ├── easy.js
│ │ │ ├── init.js
│ │ │ ├── install.js
│ │ │ ├── logger.js
│ │ │ ├── template.js
│ │ │ ├── upgrade.js
│ │ │ ├── utils.js
│ │ │ └── webpack.js
│ │ ├── package.json
│ │ ├── template
│ │ │ ├── .gitignore
│ │ │ └── learning.md
│ │ ├── test
│ │ │ ├── download.test.js
│ │ │ ├── file.test.js
│ │ │ ├── tool.test.js
│ │ │ ├── upgrade.test.js
│ │ │ └── utils.test.js
│ │ └── yarn.lock
│ ├── res-cli
│ │ ├── .eslintignore
│ │ ├── .eslintrc
│ │ ├── .gitattributes
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ ├── bin
│ │ │ └── cli.js
│ │ ├── index.js
│ │ ├── lib
│ │ │ ├── action.js
│ │ │ ├── ask.js
│ │ │ ├── command.js
│ │ │ └── config.js
│ │ ├── package.json
│ │ └── test
│ │ │ └── lib.test.js
│ ├── ves-cli
│ │ ├── .eslintignore
│ │ ├── .eslintrc
│ │ ├── .gitattributes
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── CHANGELOG.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── bin
│ │ │ └── cli.js
│ │ ├── index.js
│ │ ├── lib
│ │ │ ├── action.js
│ │ │ ├── ask.js
│ │ │ ├── command.js
│ │ │ └── config.js
│ │ ├── package.json
│ │ └── test
│ │ │ └── lib.test.js
│ └── webpack-tool
│ │ ├── .eslintignore
│ │ ├── .eslintrc
│ │ ├── .gitattributes
│ │ ├── .gitignore
│ │ ├── CHANGELOG.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── doc
│ │ └── webpack-tool-ui-view.png
│ │ ├── index.js
│ │ ├── lib
│ │ ├── dev.js
│ │ ├── history.js
│ │ ├── hot.js
│ │ ├── nav.js
│ │ ├── proxy.js
│ │ ├── tool.js
│ │ ├── utils.js
│ │ └── view.html
│ │ ├── package.json
│ │ └── test
│ │ └── index.js
├── framework
│ ├── easywebpack-js
│ │ ├── .eslintignore
│ │ ├── .eslintrc
│ │ ├── .gitattributes
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── CHANGELOG.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── config
│ │ │ └── config.js
│ │ ├── doc
│ │ │ └── images
│ │ │ │ ├── react-lib.png
│ │ │ │ └── vue-lib.png
│ │ ├── example
│ │ │ ├── react-common-lib
│ │ │ │ ├── README.md
│ │ │ │ ├── babel.config.js
│ │ │ │ ├── lib
│ │ │ │ │ └── react-mobx.js
│ │ │ │ ├── package.json
│ │ │ │ ├── test
│ │ │ │ │ ├── babel.config.js
│ │ │ │ │ ├── package.json
│ │ │ │ │ ├── src
│ │ │ │ │ │ ├── react-mobx.js
│ │ │ │ │ │ └── view
│ │ │ │ │ │ │ └── index.html
│ │ │ │ │ └── webpack.config.js
│ │ │ │ └── webpack.config.js
│ │ │ └── vue-common-lib
│ │ │ │ ├── README.md
│ │ │ │ ├── babel.config.js
│ │ │ │ ├── lib
│ │ │ │ └── vue-lib.js
│ │ │ │ ├── package.json
│ │ │ │ ├── test
│ │ │ │ ├── babel.config.js
│ │ │ │ ├── package.json
│ │ │ │ ├── src
│ │ │ │ │ ├── app.js
│ │ │ │ │ └── view
│ │ │ │ │ │ └── index.html
│ │ │ │ └── webpack.config.js
│ │ │ │ └── webpack.config.js
│ │ ├── index.js
│ │ ├── lib
│ │ │ └── client.js
│ │ ├── package.json
│ │ └── test
│ │ │ └── client.test.js
│ ├── easywebpack-react
│ │ ├── .eslintignore
│ │ ├── .eslintrc
│ │ ├── .gitattributes
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── CHANGELOG.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── config
│ │ │ ├── babel.node.js
│ │ │ ├── babel.web.js
│ │ │ ├── config.js
│ │ │ ├── plugin.js
│ │ │ └── plugin
│ │ │ │ └── react-ssr-dynamic-chunk-webpack-plugin
│ │ │ │ └── index.js
│ │ ├── index.js
│ │ ├── lib
│ │ │ ├── base.js
│ │ │ ├── client.js
│ │ │ └── server.js
│ │ ├── package.json
│ │ └── test
│ │ │ ├── client.test.js
│ │ │ ├── layout.html
│ │ │ └── server.test.js
│ ├── easywebpack-vue
│ │ ├── .eslintignore
│ │ ├── .eslintrc
│ │ ├── .gitattributes
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── CHANGELOG.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── config
│ │ │ ├── babel.node.js
│ │ │ ├── babel.web.js
│ │ │ ├── config.js
│ │ │ ├── loader.js
│ │ │ ├── plugin.js
│ │ │ └── plugin
│ │ │ │ └── vue-ssr-dynamic-chunk-webpack-plugin
│ │ │ │ └── index.js
│ │ ├── doc
│ │ │ └── images
│ │ │ │ ├── webpack-vue-compile.png
│ │ │ │ └── webpack-vue-debug.png
│ │ ├── index.js
│ │ ├── lib
│ │ │ ├── base.js
│ │ │ ├── client.js
│ │ │ ├── server.js
│ │ │ └── utils.js
│ │ ├── package.json
│ │ └── test
│ │ │ ├── client.test.js
│ │ │ ├── fixture
│ │ │ ├── vue2
│ │ │ │ └── package.json
│ │ │ └── vue3
│ │ │ │ └── package.json
│ │ │ ├── layout.html
│ │ │ ├── server.test.js
│ │ │ └── utils.test.js
│ └── easywebpack
│ │ ├── .eslintignore
│ │ ├── .eslintrc
│ │ ├── .gitattributes
│ │ ├── .gitignore
│ │ ├── .travis.yml
│ │ ├── CHANGELOG.md
│ │ ├── LICENSE
│ │ ├── README.CN.md
│ │ ├── README.md
│ │ ├── config
│ │ ├── babel.node.js
│ │ ├── babel.web.js
│ │ ├── config.js
│ │ ├── loader.js
│ │ ├── plugin.js
│ │ └── postcss.config.js
│ │ ├── docs
│ │ ├── easywebpack.md
│ │ ├── images
│ │ │ ├── easy-build-size.png
│ │ │ ├── easy-egg-react.png
│ │ │ ├── easy-egg-vue.png
│ │ │ ├── easy-init.png
│ │ │ ├── easywebpack.png
│ │ │ └── easywebpack.solution.png
│ │ └── issue_template.md
│ │ ├── index.js
│ │ ├── lib
│ │ ├── builder.js
│ │ ├── core
│ │ │ ├── config.js
│ │ │ ├── constant.js
│ │ │ ├── loader.js
│ │ │ ├── native.js
│ │ │ ├── optimize.js
│ │ │ ├── output.js
│ │ │ └── plugin.js
│ │ ├── target
│ │ │ ├── base.js
│ │ │ ├── client.js
│ │ │ ├── dll.js
│ │ │ └── server.js
│ │ └── zero.js
│ │ ├── package.json
│ │ ├── test
│ │ ├── base.test.js
│ │ ├── builder.test.js
│ │ ├── client.test.js
│ │ ├── dll.test.js
│ │ ├── entry.test.js
│ │ ├── helper.js
│ │ ├── html.test.js
│ │ ├── layout.html
│ │ ├── loader.test.js
│ │ ├── manifest.test.js
│ │ ├── optimize.test.js
│ │ ├── output.test.js
│ │ ├── plugin.test.js
│ │ ├── rule.test.js
│ │ ├── server.test.js
│ │ ├── test.test.js
│ │ ├── typescript.test.js
│ │ ├── utils.test.js
│ │ └── vue.test.js
│ │ └── utils
│ │ ├── hot.js
│ │ ├── install.js
│ │ ├── logger.js
│ │ └── utils.js
└── plugin
│ ├── react-entry-loader
│ ├── .eslintignore
│ ├── .eslintrc
│ ├── .gitattributes
│ ├── .gitignore
│ ├── .travis.yml
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── index.js
│ ├── lib
│ │ ├── node.js
│ │ └── web.js
│ ├── package.json
│ └── test
│ │ └── lib.test.js
│ └── vue-entry-loader
│ ├── .eslintignore
│ ├── .eslintrc
│ ├── .gitattributes
│ ├── .gitignore
│ ├── .travis.yml
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── index.js
│ ├── lib
│ ├── node.js
│ └── web.js
│ ├── package.json
│ └── test
│ └── lib.test.js
└── yarn.lock
/.all-contributorsrc:
--------------------------------------------------------------------------------
1 | {
2 | "projectName": "easywebpack",
3 | "projectOwner": "hubcarl",
4 | "repoType": "github",
5 | "repoHost": "https://github.com",
6 | "files": [
7 | "README.md"
8 | ],
9 | "imageSize": 100,
10 | "commit": true,
11 | "commitConvention": "angular",
12 | "contributors": [
13 | {
14 | "login": "hubcarl",
15 | "name": "sky",
16 | "avatar_url": "https://avatars2.githubusercontent.com/u/4983042?v=4",
17 | "profile": "https://easyjs.cn",
18 | "contributions": [
19 | "code",
20 | "doc"
21 | ]
22 | },
23 | {
24 | "login": "jasonjcpeng",
25 | "name": "jasonjcpeng",
26 | "avatar_url": "https://avatars0.githubusercontent.com/u/13363216?v=4",
27 | "profile": "https://github.com/jasonjcpeng",
28 | "contributions": [
29 | "code",
30 | "doc"
31 | ]
32 | },
33 | {
34 | "login": "willworks",
35 | "name": "Kevin Zhong",
36 | "avatar_url": "https://avatars2.githubusercontent.com/u/5542777?v=4",
37 | "profile": "https://github.com/willworks",
38 | "contributions": [
39 | "code",
40 | "doc"
41 | ]
42 | },
43 | {
44 | "login": "HiuYanChong",
45 | "name": "HiuYanChong",
46 | "avatar_url": "https://avatars0.githubusercontent.com/u/15319816?v=4",
47 | "profile": "https://github.com/HiuYanChong",
48 | "contributions": [
49 | "code",
50 | "doc"
51 | ]
52 | },
53 | {
54 | "login": "thonatos",
55 | "name": "Suyi",
56 | "avatar_url": "https://avatars2.githubusercontent.com/u/958063?v=4",
57 | "profile": "https://www.thonatos.com",
58 | "contributions": [
59 | "code",
60 | "doc"
61 | ]
62 | },
63 | {
64 | "login": "geekdada",
65 | "name": "Roy Li",
66 | "avatar_url": "https://avatars0.githubusercontent.com/u/3274850?v=4",
67 | "profile": "https://blog.dada.li",
68 | "contributions": [
69 | "code",
70 | "doc"
71 | ]
72 | },
73 | {
74 | "login": "mice33",
75 | "name": "Mice",
76 | "avatar_url": "https://avatars2.githubusercontent.com/u/4945433?v=4",
77 | "profile": "https://github.com/mice33",
78 | "contributions": [
79 | "code",
80 | "doc"
81 | ]
82 | },
83 | {
84 | "login": "jacksky007",
85 | "name": "小杰",
86 | "avatar_url": "https://avatars3.githubusercontent.com/u/2378915?v=4",
87 | "profile": "https://github.com/jacksky007",
88 | "contributions": [
89 | "code",
90 | "doc"
91 | ]
92 | },
93 | {
94 | "login": "asins",
95 | "name": "asins",
96 | "avatar_url": "https://avatars3.githubusercontent.com/u/898354?v=4",
97 | "profile": "http://nootn.com/",
98 | "contributions": [
99 | "code",
100 | "doc"
101 | ]
102 | }
103 | ],
104 | "contributorsPerLine": 7
105 | }
106 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | test/fixtures
2 | coverage
3 | public
4 | test/web
5 | node_modules
6 | .spec.js
7 | coverage
8 | config
9 | .nyc_output
10 | *.test.js
11 | utils/hot.js
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint",
3 | "env": {
4 | "node": true,
5 | "es6": true,
6 | "mocha": true
7 | },
8 | "parserOptions": {
9 | "ecmaVersion": 6
10 | },
11 | "rules": {
12 | "indent": [
13 | "error",
14 | 2,
15 | { "SwitchCase": 1 }
16 | ],
17 | "require-jsdoc": "off",
18 | "no-loop-func": "off",
19 | "no-underscore-dangle": "off",
20 | "consistent-return": "off",
21 | "no-cond-assign": "off",
22 | "lines-around-comment": "off",
23 | "arrow-body-style": "off",
24 | "no-confusing-arrow": "off",
25 | "class-methods-use-this": "off",
26 | "newline-after-var": "off",
27 | "no-invalid-this": "off",
28 | "no-nested-ternary": "off",
29 | "no-unused-vars": "off",
30 | "eol-last": "off",
31 | "quotes": [
32 | "error",
33 | "single"
34 | ],
35 | "guard-for-in": "off",
36 | "no-console": "off",
37 | "no-undefined": "off",
38 | "array-bracket-spacing": "off",
39 | "no-unused-expressions": "off",
40 | "func-style": [
41 | "error",
42 | "expression"
43 | ],
44 | "comma-dangle": [
45 | "error",
46 | "never"
47 | ]
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=javascript
2 | *.css linguist-language=javascript
3 | *.html linguist-language=javascript
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | npm-debug.log
3 | node_modules/
4 | coverage/
5 | .idea/
6 | run/
7 | .DS_Store
8 | *.swp
9 | .vscode
10 | *.iml
11 | config/buildConfig.json
12 | temp
13 | .nyc_output
14 | coverage.lcov
15 | /package-lock.json
16 | dist
17 | app
18 | .vscode
19 | *.log
20 | package.json.lerna_backup
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '8'
5 | - '9'
6 | script:
7 | - npm test
8 | after_success:
9 | - npm run cov
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 sky
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.
22 |
--------------------------------------------------------------------------------
/docs/easywebpack.md:
--------------------------------------------------------------------------------
1 |
2 | ## 非egg应用和插件, 单元测试和覆盖率
3 |
4 | https://istanbul.js.org/docs/tutorials/mocha/
5 |
6 | ## Webpack3
7 |
8 | - http://www.cnblogs.com/wmhuang/p/7065396.html
9 | - https://github.com/shaketbaby/directory-named-webpack-plugin
--------------------------------------------------------------------------------
/docs/images/easy-build-size.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/docs/images/easy-build-size.png
--------------------------------------------------------------------------------
/docs/images/easy-egg-react.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/docs/images/easy-egg-react.png
--------------------------------------------------------------------------------
/docs/images/easy-egg-vue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/docs/images/easy-egg-vue.png
--------------------------------------------------------------------------------
/docs/images/easy-init.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/docs/images/easy-init.png
--------------------------------------------------------------------------------
/docs/images/easywebpack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/docs/images/easywebpack.png
--------------------------------------------------------------------------------
/docs/images/easywebpack.solution.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/docs/images/easywebpack.solution.png
--------------------------------------------------------------------------------
/docs/issue_template.md:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/docs/learn.md:
--------------------------------------------------------------------------------
1 | https://blog.csdn.net/i10630226/article/details/99702447
2 |
3 | ## lerna
4 |
5 | #### lerna
6 |
7 | - lerna add mocha --scope webpack-tool --dev
8 |
9 | #### yarn workspaces
10 |
11 | - yarn add eslint-config-eslint --dev -W
12 |
13 | ## webpack
14 |
15 | resolve: {
16 | symlinks: true,
17 | }
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "packages": [
3 | "packages/framework/*",
4 | "packages/plugin/*",
5 | "packages/cli/*"
6 | ],
7 | "version": "5.0.0",
8 | "command": {
9 | "bootstrap": {
10 | "hoist": false,
11 | "npmClientArgs": [
12 | "--no-package-lock",
13 | "--registry=https://registry.npmmirror.com"
14 | ]
15 | }
16 | },
17 | "npmClient": "yarn"
18 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "easywebpack",
3 | "version": "5.0.0",
4 | "private": true,
5 | "devDependencies": {
6 | "eslint": "^7.30.0",
7 | "eslint-config-eslint": "^7.0.0",
8 | "lerna": "^3.22.1"
9 | },
10 | "workspaces": [
11 | "packages/framework/*",
12 | "packages/plugin/*",
13 | "packages/cli/*"
14 | ],
15 | "scripts": {
16 | "boot": "lerna workspace",
17 | "clean": "lerna clean",
18 | "fix": "lerna run fix",
19 | "fix:res": "lerna run fix --scope @easy-team/res-cli",
20 | "fix:ves": "lerna run fix --scope ves-cli",
21 | "fix:tool": "lerna run fix --scope webpack-tool",
22 | "fix:cli": "lerna run fix --scope easywebpack-cli",
23 | "fix:easy": "lerna run fix --scope easywebpack",
24 | "fix:vue": "lerna run fix --scope easywebpack-vue",
25 | "fix:react": "lerna run fix --scope easywebpack-react",
26 | "fix:js": "lerna run fix --scope easywebpack-js",
27 | "test": "lerna run test",
28 | "test:cli": "lerna run test --scope easywebpack-cli",
29 | "test:res": "lerna run test --scope @easy-team/res-cli",
30 | "test:ves": "lerna run test --scope ves-cli",
31 | "test:easy": "lerna run test --scope easywebpack",
32 | "test:vue": "lerna run test --scope easywebpack-vue",
33 | "test:react": "lerna run test --scope easywebpack-react",
34 | "test:js": "lerna run test --scope easywebpack-js",
35 | "test:tool": "lerna run test --scope webpack-tool",
36 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/.eslintignore:
--------------------------------------------------------------------------------
1 | test/fixtures
2 | coverage
3 | public
4 | test/web
5 | node_modules
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "parserOptions": { "ecmaVersion": 8 },
4 | "rules": {
5 | "default-param-last": "off",
6 | "require-unicode-regexp": "off",
7 | "prefer-regex-literals": "off",
8 | "jsdoc/implements-on-classes": "off",
9 | "padding-line-between-statements": "off",
10 | "no-param-reassign": "off",
11 | "no-unused-vars": "off",
12 | "no-prototype-builtins": "off",
13 | "camelcase":"off",
14 | "func-style": "off",
15 | "jsdoc/require-jsdoc": "off",
16 | "jsdoc/require-description": "off",
17 | "jsdoc/require-param-description": "off",
18 | "node/no-process-exit": "off"
19 | }
20 | }
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=javascript
2 | *.css linguist-language=javascript
3 | *.html linguist-language=javascript
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | npm-debug.log
3 | node_modules/
4 | coverage/
5 | .idea/
6 | run/
7 | .DS_Store
8 | *.swp
9 | .vscode
10 | *.iml
11 | config
12 | temp
13 | .nyc_output
14 | coverage.lcov
15 | .vscode
16 | dist
17 | package-lock.json
18 | yarn-error.log
19 |
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '6'
5 | - '8'
6 | - '12'
7 | - '14'
8 | script:
9 | - npm test
10 | after_success:
11 | - npm run ci
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 sky
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.
22 |
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/bin/cli.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | 'use strict';
4 |
5 | const Command = require('../lib/command');
6 | new Command().run();
7 |
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/doc/easy-add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/cli/easywebpack-cli/doc/easy-add.png
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/doc/easy-build-s-cmd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/cli/easywebpack-cli/doc/easy-build-s-cmd.png
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/doc/easy-init-step-one.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/cli/easywebpack-cli/doc/easy-init-step-one.png
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/doc/easy-init-step-two.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/cli/easywebpack-cli/doc/easy-init-step-two.png
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/doc/easy-server-cmd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/cli/easywebpack-cli/doc/easy-server-cmd.png
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/doc/easywebpack-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/cli/easywebpack-cli/doc/easywebpack-logo.png
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/doc/issue_template.md:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | Object.assign(exports, require('./lib/builder'));
3 | exports.Action = require('./lib/action');
4 | exports.Command = require('./lib/command');
5 | exports.Download = require('./lib/download');
6 | exports.utils = require('./lib/utils');
7 | exports.WebpackTool = require('webpack-tool');
8 | exports.webpack = exports.WebpackTool.webpack;
9 | exports.merge = exports.WebpackTool.merge;
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/lib/babel.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const fs = require('fs');
4 | const Logger = require('./logger');
5 | module.exports = (baseDir, options = {}) => {
6 | const pkgFile = path.join(baseDir, 'package.json');
7 | const pkgJSON = require(pkgFile);
8 | pkgJSON.dependencies = pkgJSON.dependencies || {};
9 | pkgJSON.devDependencies = pkgJSON.devDependencies || {};
10 |
11 | const upgradePackages = {
12 | 'babel-core': {
13 | name: '@babel/core',
14 | version: '^7.0.0'
15 | },
16 | 'babel-loader': {
17 | name: 'babel-loader',
18 | version: '^8.0.0'
19 | },
20 | 'babel-plugin-transform-class-properties': {
21 | name: '@babel/plugin-proposal-class-properties',
22 | version: '^7.0.0'
23 | },
24 | 'babel-plugin-transform-object-rest-spread': {
25 | name: '@babel/plugin-proposal-object-rest-spread',
26 | version: '^7.0.0'
27 | },
28 | 'babel-plugin-syntax-dynamic-import': {
29 | name: '@babel/plugin-syntax-dynamic-import',
30 | version: '^7.0.0'
31 | },
32 | 'babel-plugin-transform-object-assign': {
33 | name: '@babel/plugin-transform-object-assign',
34 | version: '^7.0.0'
35 | },
36 | 'babel-plugin-transform-runtime': {
37 | name: '@babel/plugin-transform-runtime',
38 | version: '^7.0.0'
39 | },
40 | 'babel-preset-env': {
41 | name: '@babel/preset-env',
42 | version: '^7.0.0'
43 | },
44 | 'babel-preset-react': {
45 | name: '@babel/preset-react',
46 | version: '^7.0.0',
47 | isAdd: !!(pkgJSON.dependencies.react || pkgJSON.devDependencies.react)
48 | }
49 | };
50 |
51 |
52 | const writePackageJSON = () => {
53 | const upgradePackageNameList = Object.keys(upgradePackages);
54 | // remove and update dependencies
55 | Object.keys(pkgJSON.dependencies).forEach(key => {
56 | const has = upgradePackageNameList.some(ukey => {
57 | return ukey === key;
58 | });
59 | if (has) {
60 | delete pkgJSON.dependencies[key];
61 | const { name, version } = upgradePackages[key];
62 | pkgJSON.devDependencies[name] = version;
63 | }
64 | });
65 |
66 | // remove and update devDependencies
67 | Object.keys(pkgJSON.devDependencies).forEach(key => {
68 | const has = upgradePackageNameList.some(ukey => {
69 | return key === ukey;
70 | });
71 | if (has) {
72 | delete pkgJSON.devDependencies[key];
73 | }
74 | });
75 |
76 | Object.keys(upgradePackages).forEach(key => {
77 | const { name, version, isAdd } = upgradePackages[key];
78 | if (isAdd !== false) {
79 | pkgJSON.devDependencies[name] = version;
80 | }
81 | });
82 |
83 | fs.writeFileSync(pkgFile, JSON.stringify(pkgJSON, null, 2));
84 | };
85 |
86 | const babelrc = path.join(baseDir, '.babelrc');
87 | if (fs.existsSync(babelrc)) {
88 | const { writeBabelRC, installDeps } = require('babel-upgrade/src');
89 | writeBabelRC(babelrc, { write: true }).then(() => {
90 | writePackageJSON();
91 | Logger.getLogger().green('upgrade .babelrc and package.json successfully! Please reinstall the dependencies with npm install or yarn install');
92 | });
93 | }
94 | };
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/lib/builder.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const webpack = require('../lib/webpack');
3 | const easy = require('../lib/easy');
4 |
5 | exports.getFramework = (filepath = 'webpack.config.js', baseDir) => {
6 | return easy.getFramework(filepath, baseDir);
7 | };
8 |
9 | exports.getWebpackBuilder = (framework, baseDir) => {
10 | return easy.getWebpackBuilder(framework, baseDir);
11 | };
12 |
13 | exports.install = options => {
14 | easy.install(options);
15 | };
16 |
17 | exports.getEasy = cfg => {
18 | return easy.getEasy(cfg);
19 | };
20 |
21 | exports.getWebpackConfig = cfg => {
22 | if (cfg.cli.webpack) {
23 | return webpack.getWebpackConfig(cfg);
24 | }
25 | return easy.getWebpackConfig(cfg);
26 | };
27 |
28 | exports.build = cfg => {
29 | if (cfg.cli.webpack) {
30 | return webpack.build(cfg);
31 | }
32 | return easy.build(cfg);
33 | };
34 |
35 | exports.server = cfg => {
36 | if (cfg.cli.webpack) {
37 | return webpack.server(cfg);
38 | }
39 | return easy.server(cfg);
40 | };
41 |
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/lib/constant.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | exports.EASY_CLI = { name: 'easywebpack-cli', cmd: 'easy' };
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/lib/install.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const shell = require('shelljs');
4 | const chalk = require('chalk');
5 |
6 | if (shell.which('node')) {
7 | const NODE_COMMAND_PATH = shell.which('node').stdout;
8 | const NODE_PATH = path.join(NODE_COMMAND_PATH, '../../lib/node_modules');
9 | console.log(chalk.yellow('\r\n Please execute flow command, Add global easywebpack-cli to $NODE_PATH'));
10 | console.log(chalk.green('\r\n1. Use vim command to open bash_profile file: \r\n\r\n') + chalk.blue('vim ~/.bash_profile'));
11 | console.log(chalk.green('\r\n2. Use export command to add NODE_PATH in bash_profile: \r\n\r\n') + chalk.blue(`export NODE_PATH=${NODE_PATH}:$NODE_PATH`));
12 | console.log(chalk.green('\r\n3. Use source command to make NODE_PATH take effect immediately: \r\n\r\n') + chalk.blue('source ~/.bash_profile'));
13 | }
14 |
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/lib/logger.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const chalk = require('chalk');
3 | const { EASY_CLI } = require('./constant');
4 | class Logger {
5 |
6 | constructor(cli) {
7 | this.cli = cli;
8 | this.chalk = chalk;
9 | }
10 |
11 | static getLogger(cli) {
12 | cli = cli || global.EASY_CLI || EASY_CLI;
13 | return new Logger(cli);
14 | }
15 |
16 | /* istanbul ignore next */
17 | green(msg, ex = '') {
18 | /* istanbul ignore next */
19 | console.log(chalk.blueBright(`[${this.cli.name}] ${chalk.green(msg)}`), ex);
20 | }
21 | /* istanbul ignore next */
22 | red(msg, ex = '') {
23 | /* istanbul ignore next */
24 | console.log(chalk.blueBright(`[${this.cli.name}] ${chalk.red(msg)}`), ex);
25 | }
26 | /* istanbul ignore next */
27 | yellow(msg, ex = '') {
28 | /* istanbul ignore next */
29 | console.log(chalk.blueBright(`[${this.cli.name}] ${chalk.yellow(msg)}`), ex);
30 | }
31 | }
32 |
33 |
34 | module.exports = Logger;
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/lib/webpack.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const WebpackTool = require('webpack-tool');
4 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
5 | const StatsPlugin = require('stats-webpack-plugin');
6 | const ProgressBarPlugin = require('progress-bar-webpack-plugin');
7 | const utils = require('../lib/utils');
8 |
9 | exports.getWebpackConfig = cfg => {
10 | const { baseDir, cli } = cfg;
11 | const { filename = 'webpack.config.js' } = cli;
12 | const nativeWebpackConfigFile = path.isAbsolute(filename) ? filename : path.resolve(baseDir, filename);
13 | return require(nativeWebpackConfigFile);
14 | };
15 |
16 | exports.isRegisterPlugin = (plugins, name) => {
17 | return plugins.some(plugin => {
18 | return plugin.constructor && plugin.constructor.name === name;
19 | });
20 | };
21 |
22 | exports.normalizeWebpackConfig = cfg => {
23 | const webpackConfig = exports.getWebpackConfig(cfg);
24 | const { cli } = cfg;
25 | const { env, size, speed } = cli;
26 | const { plugins = [] } = webpackConfig;
27 |
28 | if (!webpackConfig.mode) {
29 | webpackConfig.mode = env === 'prod' ? 'production' : 'development';
30 | }
31 |
32 | if (!exports.isRegisterPlugin(plugins, 'ProgressBarPlugin')) {
33 | plugins.push(new ProgressBarPlugin());
34 | }
35 |
36 | if (size) {
37 | if (size === 'stats' && !exports.isRegisterPlugin(plugins, 'StatsPlugin')) {
38 | plugins.push(new StatsPlugin('stats.json', {
39 | chunkModules: true,
40 | exclude: [/node_modules[\\/]react/]
41 | }));
42 | } else if (!exports.isRegisterPlugin(plugins, 'BundleAnalyzerPlugin')) {
43 | plugins.push(new BundleAnalyzerPlugin());
44 | }
45 | }
46 |
47 | webpackConfig.plugins = plugins;
48 |
49 | if (speed) {
50 | return utils.createSpeedWebpackConfig(webpackConfig);
51 | }
52 |
53 | return webpackConfig;
54 | };
55 |
56 | exports.build = async cfg => {
57 | const webpackTool = new WebpackTool();
58 | const webpackConfig = exports.normalizeWebpackConfig(cfg);
59 | return webpackTool.build(webpackConfig);
60 | };
61 |
62 | exports.server = async cfg => {
63 | const { port } = cfg.cli;
64 | const webpackTool = new WebpackTool({ port });
65 | const webpackConfig = exports.normalizeWebpackConfig(cfg);
66 | return webpackTool.server(webpackConfig);
67 | };
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "easywebpack-cli",
3 | "version": "5.2.0",
4 | "description": "Webpack Building Command Line And Boilerplate Init Tool",
5 | "bin": {
6 | "easywebpack": "bin/cli.js",
7 | "easy": "bin/cli.js"
8 | },
9 | "scripts": {
10 | "lint": "eslint .",
11 | "fix": "eslint --fix .",
12 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
13 | "test-mocha": "mocha test",
14 | "test": "nyc --reporter=html --reporter=text npm run test-mocha",
15 | "cov": "nyc report --reporter=lcov > coverage.lcov && codecov --token=d7567590-d31c-4c14-8707-574d8ab10c03",
16 | "ci": "npm run lint && npm run cov",
17 | "ii": "npm install --registry https://registry.npmmirror.com"
18 | },
19 | "dependencies": {
20 | "art-template": "^4.0.0",
21 | "archive-tool": "^1.0.0",
22 | "babel-upgrade": "^1.0.1",
23 | "chalk": "^4.1.0",
24 | "commander": "^6.1.0",
25 | "compressing": "^1.2.3",
26 | "easy-puppeteer-html": "^1.0.0",
27 | "easy-template-config": "^1.2.0",
28 | "execa": "^4.0.3",
29 | "inquirer": "^7.3.3",
30 | "jsdom": "^16.4.0",
31 | "lodash.get": "^4.4.2",
32 | "mz-modules": "^2.1.0",
33 | "node-glob": "^1.2.0",
34 | "node-tool-utils": "^1.0.0",
35 | "ora": "^5.0.0",
36 | "progress-bar-webpack-plugin": "^2.1.0",
37 | "shelljs": "^0.8.5",
38 | "speed-measure-webpack-plugin": "^1.2.2",
39 | "stats-webpack-plugin": "^0.7.0",
40 | "urllib": "^2.36.1",
41 | "webpack-bundle-analyzer": "^3.0.2",
42 | "webpack-tool": "^5.0.0"
43 | },
44 | "devDependencies": {
45 | "chai": "^4.1.0",
46 | "codecov": "^3.7.0",
47 | "conventional-changelog-cli": "^2.1.0",
48 | "eslint": "^7.8.1",
49 | "istanbul": "^0.4.5",
50 | "mocha": "^8.1.3",
51 | "nyc": "^15.1.0"
52 | },
53 | "files": [
54 | "index.js",
55 | "bin",
56 | "lib",
57 | "tool"
58 | ],
59 | "nyc": {
60 | "exclude": [
61 | "**/*.spec.js",
62 | "bin/cli.js",
63 | "lib/builder.js",
64 | "lib/command.js",
65 | "index.js",
66 | "test/*.test.js"
67 | ]
68 | },
69 | "engines": {
70 | "node": ">=8.0.0"
71 | },
72 | "ci": {
73 | "version": "8, 10, 12, 14, 16, 18, 20, 22"
74 | },
75 | "publishConfig": {
76 | "registry": "https://registry.npmjs.org",
77 | "access": "public"
78 | },
79 | "repository": {
80 | "type": "git",
81 | "url": "git+https://github.com/easy-team/easywebpack-cli.git"
82 | },
83 | "author": "hubcarl@126.com",
84 | "license": "MIT",
85 | "homepage": "https://github.com/easy-team/easywebpack-cli"
86 | }
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/template/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .happypack/
3 | node_modules/
4 | npm-debug.log
5 | .idea/
6 | dist
7 | static
8 | public/
9 | private
10 | run
11 | *.iml
12 | artifacts.json
13 | tmp/
14 | *tmp
15 | _site
16 | logs
17 | .vscode
18 | config/buildConfig.json
19 | config/manifest.json
20 | app/view/*
21 | !app/view/layout.html
22 | !app/view/README.md
23 | !app/view/.gitkeep
24 | package-lock.json
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/template/learning.md:
--------------------------------------------------------------------------------
1 | ## learning
2 |
3 | ### Document
4 |
5 | - [Webpack](https://github.com/easy-team/easywebpack)
6 | - [Vue Single Application](https://github.com/easy-team/easywebpack-vue)
7 | - [React Single Application](https://github.com/easy-team/easywebpack-react)
8 | - [Vue Server Side Render](https://www.yuque.com/easy-team/egg-ves)
9 | - [React Server Side Render](https://www.yuque.com/easy-team/egg-res)
10 |
11 | ### About
12 |
13 | - [GitHub](https://github.com/easy-team)
14 | - [Doc](https://www.yuque.com/easy-team)
15 | - [Blog](https://www.yuque.com/hubcarl)
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/test/download.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const fs = require('fs');
4 | const rimraf = require('mz-modules/rimraf');
5 | const mkdirp = require('mz-modules/mkdirp');
6 | const expect = require('chai').expect;
7 | const Download = require('../lib/download');
8 |
9 | // require('co-mocha');
10 | // http://chaijs.com/api/bdd/
11 |
12 | describe('download.test.js', () => {
13 | let download;
14 | before(() => {
15 | download = new Download({}, { name: 'easywbpack-cli' });
16 | });
17 |
18 | after(() => {
19 | });
20 |
21 | beforeEach(() => {
22 | });
23 |
24 | afterEach(() => {
25 | });
26 |
27 | describe('#npm download cli test', () => {
28 | const projectDir = path.join(process.cwd(), 'dist/cli');
29 | it('should init cli config test', async () => {
30 | await download.init(projectDir, { pkgName: 'easywebpack-cli-template' });
31 | });
32 |
33 | it('should init egg-react-webpack-boilerplate test', async () => {
34 | await download.init(projectDir, { pkgName: 'egg-react-webpack-boilerplate' });
35 | });
36 | });
37 |
38 | describe('#npm download vue boilerplate test', () => {
39 | const vueBoilerplate = 'egg-vue-webpack-boilerplate';
40 | it('should getPackageInfo', async () => {
41 | const pkgInfo = await download.getPackageInfo(vueBoilerplate);
42 | expect(pkgInfo.dist.tarball).include(vueBoilerplate);
43 | });
44 | });
45 |
46 | describe('#npm download vue boilerplate and copy test', () => {
47 | it('should download and copy', async () => {
48 | const vueBoilerplate = 'egg-vue-webpack-boilerplate';
49 | const downloadDir = await download.download(vueBoilerplate, '');
50 | const sourceDir = downloadDir;
51 | const targetDir = path.join(process.cwd(), `dist/${vueBoilerplate}`);
52 | await rimraf(targetDir);
53 | await mkdirp(targetDir);
54 | download.copy(sourceDir, targetDir, { hide: true });
55 | download.updatePackageFile(targetDir);
56 | expect(fs.existsSync(path.join(targetDir, 'app/router.js'))).to.be.true;
57 | expect(fs.existsSync(path.join(targetDir, 'babel.config.js'))).to.be.true;
58 | });
59 | });
60 | });
61 |
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/test/file.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const fs = require('fs');
4 | const rimraf = require('mz-modules/rimraf');
5 | const mkdirp = require('mz-modules/mkdirp');
6 | const expect = require('chai').expect;
7 |
8 | // require('co-mocha');
9 | // http://chaijs.com/api/bdd/
10 |
11 | describe('file.test.js', () => {
12 | before(() => {
13 |
14 | });
15 | after(() => {
16 | });
17 |
18 | beforeEach(() => {
19 | });
20 |
21 | afterEach(() => {
22 | });
23 |
24 | describe('#file test', () => {
25 | it('should cli file', () => {
26 | const cli = require('../bin/cli');
27 | expect(!!cli).to.be.true;
28 | });
29 | it('should builder file', () => {
30 | const builder = require('../lib/builder');
31 | expect(!!builder).to.be.true;
32 | });
33 | it('should command file', () => {
34 | const command = require('../lib/command');
35 | expect(!!command).to.be.true;
36 | });
37 | it('should builder file', () => {
38 | const download = require('../lib/download');
39 | expect(!!download).to.be.true;
40 | });
41 | it('should builder file', () => {
42 | const install = require('../lib/install');
43 | expect(!!install).to.be.true;
44 | });
45 | it('should upgrade file', () => {
46 | const upgrade = require('../lib/upgrade');
47 | expect(!!upgrade).to.be.true;
48 | });
49 | it('should utils file', () => {
50 | const utils = require('../lib/utils');
51 | expect(!!utils).to.be.true;
52 | });
53 | });
54 | });
55 |
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/test/tool.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const fs = require('fs');
4 | const rimraf = require('mz-modules/rimraf');
5 | const mkdirp = require('mz-modules/mkdirp');
6 | const expect = require('chai').expect;
7 | const tool = require('node-tool-utils');
8 | const baseDir = process.cwd();
9 | // require('co-mocha');
10 | // http://chaijs.com/api/bdd/
11 |
12 | describe('tool.test.js', () => {
13 | before(() => {
14 |
15 | });
16 | after(() => {});
17 |
18 | beforeEach(() => {});
19 |
20 | afterEach(() => {});
21 |
22 | describe('#tool test', () => {
23 | it('should utils deleteFile test', function *() {
24 | const dist = path.join(baseDir, 'dist');
25 | const target = path.posix.join(dist, 'test/test/test.json');
26 | yield mkdirp(path.dirname(target));
27 | fs.writeFileSync(target, 'clearManifest');
28 | expect(fs.existsSync(target)).to.be.true;
29 | tool.deleteFile(dist);
30 | expect(fs.existsSync(target)).to.be.false;
31 | });
32 | });
33 | });
--------------------------------------------------------------------------------
/packages/cli/easywebpack-cli/test/upgrade.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const fs = require('fs');
4 | const rimraf = require('mz-modules/rimraf');
5 | const mkdirp = require('mz-modules/mkdirp');
6 | const expect = require('chai').expect;
7 | const upgrade = require('../lib/upgrade');
8 | const tool = require('node-tool-utils');
9 | const baseDir = process.cwd();
10 | // require('co-mocha');
11 | // http://chaijs.com/api/bdd/
12 |
13 | describe('upgrade.test.js', () => {
14 | before(() => {
15 |
16 | });
17 | after(() => {});
18 |
19 | beforeEach(() => {});
20 |
21 | afterEach(() => {});
22 |
23 | describe('#upgrade test', () => {
24 | it('should utils deleteFile test', function *() {
25 | const pkgFile = path.posix.join(baseDir, 'test/package.json');
26 | const target = path.join(baseDir, 'disttest/package.json');
27 | const targetDir = path.dirname(target);
28 | yield mkdirp(targetDir);
29 | fs.writeFileSync(target, JSON.stringify(require(pkgFile), null, 2), 'utf8');
30 | expect(fs.existsSync(target)).to.be.true;
31 | upgrade(targetDir);
32 | const targetPkgJSON = require(target);
33 | const dependencies = targetPkgJSON.dependencies;
34 | const devDependencies = targetPkgJSON.devDependencies;
35 | expect(dependencies['server-side-render-resource']).to.be.undefined;
36 | expect(dependencies['vue-server-renderer']).to.be.undefined;
37 | expect(dependencies['progress-bar-webpack-plugin']).to.be.undefined;
38 | expect(dependencies['webpack-manifest-resource-plugin']).to.be.undefined;
39 | expect(dependencies['babel-core']).to.be.undefined;
40 | expect(dependencies['babel-loader']).to.be.undefined;
41 | expect(dependencies['eslint-loader']).to.be.undefined;
42 | tool.deleteFile(targetDir);
43 | });
44 | });
45 | });
--------------------------------------------------------------------------------
/packages/cli/res-cli/.eslintignore:
--------------------------------------------------------------------------------
1 | test/fixtures
2 | coverage
3 | public
4 | test/web
5 | node_modules
6 | .spec.js
7 | coverage
8 | config
9 | .nyc_output
10 | *.test.js
--------------------------------------------------------------------------------
/packages/cli/res-cli/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "parserOptions": { "ecmaVersion": 8 },
4 | "rules": {
5 | "default-param-last": "off",
6 | "require-unicode-regexp": "off",
7 | "prefer-regex-literals": "off",
8 | "jsdoc/implements-on-classes": "off",
9 | "padding-line-between-statements": "off",
10 | "no-param-reassign": "off",
11 | "no-unused-vars": "off",
12 | "no-prototype-builtins": "off",
13 | "camelcase":"off",
14 | "func-style": "off",
15 | "jsdoc/require-jsdoc": "off"
16 | }
17 | }
--------------------------------------------------------------------------------
/packages/cli/res-cli/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=javascript
2 | *.css linguist-language=javascript
3 | *.html linguist-language=javascript
--------------------------------------------------------------------------------
/packages/cli/res-cli/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | npm-debug.log
3 | node_modules/
4 | coverage/
5 | .idea/
6 | run/
7 | .DS_Store
8 | *.swp
9 | package-lock.json
10 | yarn.lock
11 |
12 |
--------------------------------------------------------------------------------
/packages/cli/res-cli/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '6'
5 | - '8'
6 | - '9'
7 | script:
8 | - npm test
9 | after_success:
10 | - npm run ci
11 |
--------------------------------------------------------------------------------
/packages/cli/res-cli/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 | # [2.0.0](https://github.com/easy-team/res-cli/compare/1.0.1...2.0.0) (2020-02-08)
3 |
4 |
5 |
6 |
7 | ## [1.0.1](https://github.com/easy-team/res-cli/compare/1.0.0...1.0.1) (2019-10-17)
8 |
9 |
10 | ### Bug Fixes
11 |
12 | * init and npm start for res ([c129a29](https://github.com/easy-team/res-cli/commit/c129a29))
13 |
14 |
15 |
16 |
17 | # 1.0.0 (2019-10-13)
18 |
19 |
20 | ### Features
21 |
22 | * res framework cli ([fcfe4da](https://github.com/easy-team/res-cli/commit/fcfe4da))
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/packages/cli/res-cli/README.md:
--------------------------------------------------------------------------------
1 | # res-cli
2 |
3 | A Powerful Cross-platform Node React Web Framework CLI.
4 |
5 | ## Installation
6 |
7 | ```bash
8 | $ npm install -g @easy-team/res-cli
9 | ```
10 |
11 | Node.js >= 8.0.0 required.
12 |
13 | ## Features
14 |
15 | - ✔︎ Res Application Development, such as `res dev`, `res start`, `res build`, `res lang`
16 | - ✔︎ Build with Webpack, such as `res build`, `res build --server`, `res build --speed`, `res build --size`
17 | - ✔︎ Common Development Commands, such as `res open`, `res server`
18 |
19 | ## QuickStart
20 |
21 | - Init Application
22 |
23 | ```bash
24 | $ res init
25 | ```
26 |
27 | - Development mode startup Application
28 |
29 | ```bash
30 | $ res dev
31 | ```
32 |
33 | - Publish mode startup Application
34 |
35 | ```bash
36 | $ res build
37 | $ res build --server
38 | ```
39 |
40 | - Webpack build size analysis
41 |
42 | ```bash
43 | $ res build --size
44 | ```
45 |
46 |
47 | ## Document
48 |
49 | https://yuque.com/easy-team/res
50 |
51 | ## Links
52 |
53 | https://yuque.com/easy-team/egg-react
--------------------------------------------------------------------------------
/packages/cli/res-cli/bin/cli.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | 'use strict';
4 |
5 | const Command = require('../lib/command');
6 | new Command().run();
7 |
8 |
9 |
--------------------------------------------------------------------------------
/packages/cli/res-cli/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = exports = require('./lib/config');
3 | exports.Action = require('./lib/action');
4 | exports.Command = require('./lib/command');
--------------------------------------------------------------------------------
/packages/cli/res-cli/lib/action.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const EasyCLI = require('@easy-team/easywebpack-cli');
3 | const Command = require('egg-bin');
4 | const ScriptCommand = require('egg-scripts');
5 | const Config = require('./config');
6 | module.exports = class ResAction extends EasyCLI.Action {
7 |
8 | constructor(command) {
9 | super(command);
10 | }
11 |
12 | initCustomizeConfig(options) {
13 | return Config.getResConfig(options);
14 | }
15 |
16 | dev() {
17 | const cmd = ['dev', '--framework', '@easy-team/res'];
18 | if (EasyCLI.utils.isEggTypeScriptProject(this.baseDir)) {
19 | cmd.push('-r');
20 | cmd.push('egg-ts-helper/register');
21 | }
22 | new Command(cmd).start();
23 | }
24 |
25 | debug() {
26 | const cmd = ['debug', '--framework', '@easy-team/res'];
27 | if (EasyCLI.utils.isEggTypeScriptProject(this.baseDir)) {
28 | cmd.push('-r');
29 | cmd.push('egg-ts-helper/register');
30 | }
31 | new Command(cmd).start();
32 | }
33 |
34 | test() {
35 | new Command(['test']).start();
36 | }
37 |
38 | cov() {
39 | new Command(['cov']).start();
40 | }
41 |
42 | start() {
43 | new ScriptCommand(['start', '--framework', '@easy-team/res']).start();
44 | }
45 |
46 | tsc() {
47 | const filepath = require.resolve('typescript/lib/tsc.js');
48 | this.command.tool.exec(`node ${filepath}`);
49 | }
50 |
51 | };
--------------------------------------------------------------------------------
/packages/cli/res-cli/lib/ask.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const chalk = require('chalk');
3 | exports.boilerplateChoice = [
4 | {
5 | name: `Create ${chalk.green('React')} ${chalk.yellow('Server Side Render')} Web Application for Res`,
6 | value: 'res-react-asset-boilerplate',
7 | pkgName: 'res-react-asset-boilerplate',
8 | choices: ['name', 'description', 'npm']
9 | },
10 | {
11 | name: `Create ${chalk.green('React')} ${chalk.yellow('Client Side Render')} Web Application for Res`,
12 | value: 'res-react-spa-boilerplate',
13 | pkgName: 'res-react-spa-boilerplate',
14 | choices: ['name', 'description', 'npm']
15 | },
16 | {
17 | name: `Create ${chalk.green('React')} ${chalk.yellow('Nunjucks HTML Render')} Web Application for Res`,
18 | value: 'res-react-html-boilerplate',
19 | pkgName: 'res-react-html-boilerplate',
20 | choices: ['name', 'description', 'npm']
21 | },
22 | {
23 | name: `Create ${chalk.green('React')} ${chalk.yellow('Nunjucks Asset Render')} Web Application for Res`,
24 | value: 'res-react-asset-boilerplate',
25 | pkgName: 'res-react-asset-boilerplate',
26 | choices: ['name', 'description', 'npm']
27 | },
28 | {
29 | name: `Create ${chalk.green('React')} ${chalk.yellow('TypeScript')} Awesome Web Application for Res`,
30 | value: 'res-awesome',
31 | pkgName: 'res-awesome',
32 | choices: ['name', 'description', 'npm']
33 | },
34 | ];
--------------------------------------------------------------------------------
/packages/cli/res-cli/lib/command.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const EasyCLI = require('@easy-team/easywebpack-cli');
4 | const Action = require('./action');
5 |
6 | module.exports = class ResCommand extends EasyCLI.Command {
7 |
8 | constructor() {
9 | super();
10 | this.cli.name = 'res-cli';
11 | this.cli.cmd = 'res';
12 | this.context = path.resolve(__dirname, '..');
13 | this.program.filename = path.resolve(this.baseDir, 'config/res.config.js');
14 | this.action = new Action(this);
15 | }
16 |
17 | init() {
18 | this.boilerplate = require('./ask');
19 | super.init();
20 | }
21 |
22 | tsc() {
23 | this.program
24 | .command('tsc')
25 | .option('-p, --project [filename]', 'tsconfig.json file path', this.baseDir)
26 | .description('typescript compile')
27 | .action(options => {
28 | this.action.tsc(options);
29 | });
30 | }
31 |
32 | command() {
33 | this.register('tsc');
34 | super.command();
35 | }
36 | };
--------------------------------------------------------------------------------
/packages/cli/res-cli/lib/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const fs = require('fs');
4 | const merge = require('webpack-merge');
5 | const easywebpack = require('@easy-team/easywebpack-react');
6 |
7 | exports.getResWebpackFileConfig = baseDir => {
8 | const filepath = path.resolve(baseDir, 'config/res.config.js');
9 | if (fs.existsSync(filepath)) {
10 | return require(filepath);
11 | }
12 | return {};
13 | };
14 |
15 | exports.getResConfig = (options = {}) => {
16 | const { baseDir = process.cwd(), env } = options;
17 | const baseConfig = {
18 | baseDir,
19 | framework: 'react',
20 | configured: true,
21 | egg: true,
22 | output: {
23 | path: path.join(baseDir, 'app/public')
24 | },
25 | module: {
26 | rules: [
27 | {
28 | ts: true
29 | },
30 | {
31 | scss: true
32 | },
33 | {
34 | stylus: true
35 | },
36 | {
37 | less: true
38 | }
39 | ]
40 | }
41 | };
42 | const resConfig = exports.getResWebpackFileConfig(baseDir);
43 | return merge(baseConfig, resConfig, options);
44 | };
45 |
46 | exports.getWebpackConfig = (options = {}) => {
47 | const config = exports.getResConfig(options);
48 | return easywebpack.getWebpackConfig(config);
49 | };
--------------------------------------------------------------------------------
/packages/cli/res-cli/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@easy-team/res-cli",
3 | "version": "3.0.0",
4 | "description": "Node React Web Framework CLI",
5 | "bin": {
6 | "res": "bin/cli.js"
7 | },
8 | "keywords": [
9 | "npm",
10 | "npm package",
11 | "unit test",
12 | "eslint",
13 | "travis",
14 | "travis-ci",
15 | "code coverage",
16 | "changelog"
17 | ],
18 | "dependencies": {
19 | "easywebpack-cli": "^5.0.0",
20 | "easywebpack-react": "^5.0.0",
21 | "@types/react": "^16.0.34",
22 | "@types/react-dom": "^16.0.3",
23 | "egg-bin": "^4.13.2",
24 | "egg-scripts": "^2.11.0",
25 | "egg-webpack": "^5.0.0",
26 | "egg-webpack-react": "^3.0.0",
27 | "eslint-config-egg": "^5.1.1",
28 | "eslint-plugin-react": "^7.1.0",
29 | "less": "^2.7.2",
30 | "less-loader": "^4.0.5",
31 | "stylus": "^0.54.5",
32 | "stylus-loader": "^3.0.0",
33 | "node-tool-utils": "^1.1.1",
34 | "ts-loader": "^6.0.0",
35 | "tslint": "^5.9.1",
36 | "tslint-loader": "^3.5.3",
37 | "typescript": "^3.0.0"
38 | },
39 | "devDependencies": {
40 | "chai": "^4.1.1",
41 | "codecov": "^3.0.0",
42 | "conventional-changelog-cli": "^1.3.5",
43 | "cross-env": "^5.0.5",
44 | "eslint": "^4.5.0",
45 | "eslint-config-eslint": "^4.0.0",
46 | "mocha": "^3.5.0",
47 | "nyc": "^11.1.0"
48 | },
49 | "engines": {
50 | "node": ">=8.0.0"
51 | },
52 | "scripts": {
53 | "lint": "eslint .",
54 | "fix": "eslint --fix .",
55 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
56 | "test": "egg-bin test",
57 | "cov": "egg-bin cov",
58 | "ci": "npm run lint && npm run cov",
59 | "ii": "npm install --registry https://registry.npmmirror.com"
60 | },
61 | "nyc": {
62 | "exclude": [
63 | "**/*.spec.js",
64 | "test/*.test.js"
65 | ]
66 | },
67 | "ci": {
68 | "version": "10, 12, 14"
69 | },
70 | "publishConfig": {
71 | "tag": "next"
72 | },
73 | "repository": {
74 | "type": "git",
75 | "url": "git+https://github.com/easy-team/res-cli.git"
76 | },
77 | "author": "sky"
78 | }
--------------------------------------------------------------------------------
/packages/cli/res-cli/test/lib.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const expect = require('chai').expect;
3 | // http://chaijs.com/api/bdd/
4 | describe('lib.test.js', () => {
5 | before(() => {
6 | });
7 |
8 | after(() => {
9 | });
10 |
11 | beforeEach(() => {
12 | });
13 |
14 | afterEach(() => {
15 | });
16 |
17 | describe('#expect lib test', () => {
18 | it('should unit api test', () => {
19 | expect(true).to.be.true;
20 | expect(false).to.be.false;
21 | expect(undefined).to.be.undefined;
22 | expect([1,2,3]).to.have.property(1);
23 | expect(['.js','.jsx','.vue']).to.include.members(['.js','.jsx']);
24 | expect({id: 1, name: 'sky'}).to.include.all.keys(['id', 'name']);
25 | });
26 | });
27 | });
--------------------------------------------------------------------------------
/packages/cli/ves-cli/.eslintignore:
--------------------------------------------------------------------------------
1 | test/fixtures
2 | coverage
3 | public
4 | test/web
5 | node_modules
6 | .spec.js
7 | coverage
8 | config
9 | .nyc_output
10 | *.test.js
--------------------------------------------------------------------------------
/packages/cli/ves-cli/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "parserOptions": { "ecmaVersion": 8 },
4 | "rules": {
5 | "default-param-last": "off",
6 | "require-unicode-regexp": "off",
7 | "prefer-regex-literals": "off",
8 | "jsdoc/implements-on-classes": "off",
9 | "padding-line-between-statements": "off",
10 | "no-param-reassign": "off",
11 | "no-unused-vars": "off",
12 | "no-prototype-builtins": "off",
13 | "camelcase":"off",
14 | "func-style": "off",
15 | "jsdoc/require-jsdoc": "off"
16 | }
17 | }
--------------------------------------------------------------------------------
/packages/cli/ves-cli/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=javascript
2 | *.css linguist-language=javascript
3 | *.html linguist-language=javascript
--------------------------------------------------------------------------------
/packages/cli/ves-cli/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | npm-debug.log
3 | node_modules/
4 | coverage/
5 | .idea/
6 | run/
7 | .DS_Store
8 | *.swp
9 | package-lock.json
10 | yarn.lock
11 |
12 |
--------------------------------------------------------------------------------
/packages/cli/ves-cli/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '6'
5 | - '8'
6 | - '9'
7 | script:
8 | - npm test
9 | after_success:
10 | - npm run ci
11 |
--------------------------------------------------------------------------------
/packages/cli/ves-cli/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 | ## [2.0.2](https://github.com/ves-team/ves-cli/compare/2.0.1...2.0.2) (2019-10-17)
3 |
4 |
5 | ### Bug Fixes
6 |
7 | * package.json no egg.framework config ([fba1a3b](https://github.com/ves-team/ves-cli/commit/fba1a3b))
8 |
9 |
10 |
11 |
12 | ## [2.0.1](https://github.com/ves-team/ves-cli/compare/2.0.0...2.0.1) (2019-10-11)
13 |
14 |
15 | ### Bug Fixes
16 |
17 | * webpack plugin default copy plugin ([149fa1a](https://github.com/ves-team/ves-cli/commit/149fa1a))
18 |
19 |
20 |
21 |
22 | # [2.0.0](https://github.com/ves-team/ves-cli/compare/2.0.0-beta.2...2.0.0) (2019-10-11)
23 |
24 |
25 | ### Features
26 |
27 | * tsc compile by ves tsc ([e719e9a](https://github.com/ves-team/ves-cli/commit/e719e9a))
28 |
29 |
30 |
31 |
32 | # [2.0.0-beta.2](https://github.com/ves-team/ves-cli/compare/1.0.0...2.0.0-beta.2) (2019-10-10)
33 |
34 |
35 | ### Bug Fixes
36 |
37 | * not typescript support ([20e2dd7](https://github.com/ves-team/ves-cli/commit/20e2dd7))
38 |
39 |
40 | ### Features
41 |
42 | * perfermance webpack config and use easy-team mode ([8234297](https://github.com/ves-team/ves-cli/commit/8234297))
43 |
44 |
45 |
46 |
47 | # [1.0.0](https://github.com/ves-team/ves-cli/compare/0.1.2...1.0.0) (2019-03-11)
48 |
49 |
50 | ### Features
51 |
52 | * hotcss and cssExtract default ([1b1699d](https://github.com/ves-team/ves-cli/commit/1b1699d))
53 | * public to app/public ([a0b08ac](https://github.com/ves-team/ves-cli/commit/a0b08ac))
54 |
55 |
56 |
57 |
58 | ## [0.1.2](https://github.com/ves-team/ves-cli/compare/0.1.1...0.1.2) (2018-10-30)
59 |
60 |
61 | ### Bug Fixes
62 |
63 | * webpack default config ([bf5ce0d](https://github.com/ves-team/ves-cli/commit/bf5ce0d))
64 |
65 |
66 |
67 |
68 | ## [0.1.1](https://github.com/ves-team/ves-cli/compare/0.1.0...0.1.1) (2018-10-25)
69 |
70 |
71 | ### Bug Fixes
72 |
73 | * sensitive case ([73cec66](https://github.com/ves-team/ves-cli/commit/73cec66))
74 |
75 |
76 |
77 |
78 | # 0.1.0 (2018-10-25)
79 |
80 |
81 | ### Features
82 |
83 | * init ([8d7b82c](https://github.com/ves-team/ves-cli/commit/8d7b82c))
84 | * init ([140a01f](https://github.com/ves-team/ves-cli/commit/140a01f))
85 | * support typescript build ([c31a623](https://github.com/ves-team/ves-cli/commit/c31a623))
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/packages/cli/ves-cli/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 easy-team
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.
22 |
--------------------------------------------------------------------------------
/packages/cli/ves-cli/README.md:
--------------------------------------------------------------------------------
1 | # ves-cli
2 |
3 | [![NPM version][npm-image]][npm-url]
4 | [![build status][travis-image]][travis-url]
5 | [![Test coverage][codecov-image]][codecov-url]
6 | [![David deps][david-image]][david-url]
7 | [![Known Vulnerabilities][snyk-image]][snyk-url]
8 | [![npm download][download-image]][download-url]
9 |
10 | [npm-image]: https://img.shields.io/npm/v/ves-cli.svg?style=flat-square
11 | [npm-url]: https://npmjs.org/package/ves-cli
12 | [travis-image]: https://img.shields.io/travis/easy-team/ves-cli.svg?style=flat-square
13 | [travis-url]: https://travis-ci.org/easy-team/ves-cli
14 | [codecov-image]: https://img.shields.io/codecov/c/github/easy-team/ves-cli.svg?style=flat-square
15 | [codecov-url]: https://codecov.io/github/easy-team/ves-cli?branch=master
16 | [david-image]: https://img.shields.io/david/easy-team/ves-cli.svg?style=flat-square
17 | [david-url]: https://david-dm.org/easy-team/ves-cli
18 | [snyk-image]: https://snyk.io/test/npm/ves-cli/badge.svg?style=flat-square
19 | [snyk-url]: https://snyk.io/test/npm/ves-cli
20 | [download-image]: https://img.shields.io/npm/dm/ves-cli.svg?style=flat-square
21 | [download-url]: https://npmjs.org/package/ves-cli
22 |
23 | A Powerful Cross-platform [Ves](https://github.com/easy-team/ves) Node Framework CLI Tool.
24 |
25 | ## Installation
26 |
27 | ```bash
28 | $ npm install -g ves-cli
29 | ```
30 |
31 | Node.js >= 8.0.0 required.
32 |
33 | ## Features
34 |
35 | - ✔︎ Ves Application Development, such as `ves dev`, `ves start`, `ves debug`, `ves test`
36 | - ✔︎ Build with Webpack + TypeScript, such as `ves build`, `ves build --speed`, `ves build --size`
37 | - ✔︎ Common Development Commands, such as `ves open`, `ves kill`, `ves server`
38 |
39 | ## QuickStart
40 |
41 | - Init Application
42 |
43 | ```bash
44 | $ ves init
45 | ```
46 |
47 | - Development mode startup Application
48 |
49 | ```bash
50 | $ ves dev
51 | ```
52 |
53 | - Publish mode startup Application
54 |
55 | ```bash
56 | $ ves build
57 | $ ves start
58 | ```
59 |
60 | - Webpack build size analysis
61 |
62 | ```bash
63 | $ ves build --size
64 | ```
65 |
66 | - TypeScript build
67 |
68 | ```bash
69 | $ ves tsc
70 | ```
71 |
72 | ## Examples
73 |
74 | See [ves-amdin](https://github.com/easy-team/ves-admin)
75 |
76 | ## Links
77 |
78 | - https://github.com/easy-team/ves
79 | - https://github.com/easy-team/easywebpack-cli
80 | - https://www.yuque.com/easy-team/ves
81 |
82 | ## License
83 |
84 | [MIT](LICENSE)
85 |
--------------------------------------------------------------------------------
/packages/cli/ves-cli/bin/cli.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | 'use strict';
4 |
5 | const Command = require('../lib/command');
6 | new Command().run();
7 |
8 |
9 |
--------------------------------------------------------------------------------
/packages/cli/ves-cli/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = exports = require('./lib/config');
3 | exports.Action = require('./lib/action');
4 | exports.Command = require('./lib/command');
--------------------------------------------------------------------------------
/packages/cli/ves-cli/lib/action.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const EasyCLI = require('@easy-team/easywebpack-cli');
3 | const Command = require('egg-bin');
4 | const ScriptCommand = require('egg-scripts');
5 | const Config = require('./config');
6 | module.exports = class VesAction extends EasyCLI.Action {
7 |
8 | constructor(command) {
9 | super(command);
10 | }
11 |
12 | initCustomizeConfig(options) {
13 | return Config.getVesConfig(options);
14 | }
15 |
16 |
17 | dev() {
18 | const cmd = ['dev', '--framework', 'ves'];
19 | if (EasyCLI.utils.isEggTypeScriptProject(this.baseDir)) {
20 | cmd.push('-r');
21 | cmd.push('egg-ts-helper/register');
22 | }
23 | new Command(cmd).start();
24 | }
25 |
26 | debug() {
27 | const cmd = ['debug', '--framework', 'ves'];
28 | if (EasyCLI.utils.isEggTypeScriptProject(this.baseDir)) {
29 | cmd.push('-r');
30 | cmd.push('egg-ts-helper/register');
31 | }
32 | new Command(cmd).start();
33 | }
34 |
35 | test() {
36 | new Command(['test']).start();
37 | }
38 |
39 | cov() {
40 | new Command(['cov']).start();
41 | }
42 |
43 | start() {
44 | new ScriptCommand(['start', '--framework', 'ves']).start();
45 | }
46 |
47 | tsc() {
48 | const filepath = require.resolve('typescript/lib/tsc.js');
49 | this.command.tool.exec(`node ${filepath}`);
50 | }
51 |
52 | };
--------------------------------------------------------------------------------
/packages/cli/ves-cli/lib/ask.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const chalk = require('chalk');
3 | exports.boilerplateChoice = [
4 | {
5 | name: `Create ${chalk.green('Ves + TypeScript')} ${chalk.yellow('Server Side Render')} Web Application`,
6 | value: 'ves-blog',
7 | pkgName: 'ves-blog',
8 | choices: ['name', 'description', 'npm']
9 | },
10 | {
11 | name: `Create ${chalk.green('Ves + TypeScript')} ${chalk.yellow('Server Side Render')} Admin Application`,
12 | value: 'ves-admin',
13 | pkgName: 'ves-admin',
14 | choices: ['name', 'description', 'npm']
15 | },
16 | ];
--------------------------------------------------------------------------------
/packages/cli/ves-cli/lib/command.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const EasyCLI = require('@easy-team/easywebpack-cli');
4 | const Action = require('./action');
5 |
6 | module.exports = class VesCommand extends EasyCLI.Command {
7 |
8 | constructor() {
9 | super();
10 | this.cli.name = 'ves-cli';
11 | this.cli.cmd = 'ves';
12 | this.context = path.resolve(__dirname, '..');
13 | this.program.filename = path.resolve(this.baseDir, 'config/ves.config.js');
14 | this.action = new Action(this);
15 | }
16 |
17 | init() {
18 | this.boilerplate = require('./ask');
19 | super.init();
20 | }
21 |
22 | tsc() {
23 | this.program
24 | .command('tsc')
25 | .option('-p, --project [filename]', 'tsconfig.json file path', this.baseDir)
26 | .description('typescript compile')
27 | .action(options => {
28 | this.action.tsc(options);
29 | });
30 | }
31 |
32 | command() {
33 | this.register('tsc');
34 | super.command();
35 | }
36 | };
--------------------------------------------------------------------------------
/packages/cli/ves-cli/lib/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const fs = require('fs');
4 | const merge = require('webpack-merge');
5 | const easywebpack = require('@easy-team/easywebpack-vue');
6 |
7 | exports.getVesWebpackFileConfig = baseDir => {
8 | const filepath = path.resolve(baseDir, 'config/ves.config.js');
9 | if (fs.existsSync(filepath)) {
10 | return require(filepath);
11 | }
12 | return {};
13 | };
14 |
15 | exports.getVesConfig = (options = {}) => {
16 | const { baseDir = process.cwd() } = options;
17 | const baseConfig = {
18 | baseDir,
19 | framework: 'vue',
20 | configured: true,
21 | egg: true,
22 | output: {
23 | path: path.join(baseDir, 'app/public')
24 | },
25 | module: {
26 | rules: [
27 | {
28 | ts: true
29 | },
30 | {
31 | scss: true
32 | },
33 | {
34 | stylus: true
35 | },
36 | {
37 | less: true
38 | }
39 | ]
40 | },
41 | plugins:[]
42 | };
43 | const config = exports.getVesWebpackFileConfig(baseDir);
44 | const assetpath = path.resolve(baseDir, 'app/web/asset');
45 | if (fs.existsSync(assetpath)) {
46 | baseConfig.plugins.push({
47 | copy: [{
48 | from: 'app/web/asset',
49 | to: 'asset'
50 | }]
51 | });
52 | }
53 | return merge(baseConfig, config, options);
54 | };
55 |
56 | exports.getWebpackConfig = (options = {}) => {
57 | const vesConfig = exports.getVesConfig(options);
58 | return easywebpack.getWebpackConfig(vesConfig);
59 | };
--------------------------------------------------------------------------------
/packages/cli/ves-cli/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ves-cli",
3 | "version": "3.0.0",
4 | "description": "ves framework cli",
5 | "bin": {
6 | "ves": "bin/cli.js"
7 | },
8 | "keywords": [
9 | "npm",
10 | "npm package",
11 | "unit test",
12 | "eslint",
13 | "travis",
14 | "travis-ci",
15 | "code coverage",
16 | "changelog"
17 | ],
18 | "dependencies": {
19 | "easywebpack-cli": "^5.0.0",
20 | "easywebpack-vue": "^5.0.0",
21 | "@types/node": "^10.12.0",
22 | "egg-bin": "^4.9.0",
23 | "egg-scripts": "^2.10.0",
24 | "egg-ts-helper": "^1.13.0",
25 | "less": "^2.7.2",
26 | "less-loader": "^4.0.5",
27 | "node-tool-utils": "^1.1.1",
28 | "stylus": "^0.54.5",
29 | "stylus-loader": "^3.0.0",
30 | "ts-loader": "^5.3.0",
31 | "ts-node": "^7.0.1",
32 | "tslint": "^5.9.1",
33 | "tslint-loader": "^3.5.3",
34 | "typescript": "^3.0.0",
35 | "vue-property-decorator": "^7.2.0",
36 | "vuex-class": "^0.3.1",
37 | "webpack-merge": "^4.1.4"
38 | },
39 | "devDependencies": {
40 | "chai": "^4.1.1",
41 | "codecov": "^3.0.0",
42 | "conventional-changelog-cli": "^1.3.5",
43 | "cross-env": "^5.0.5",
44 | "eslint": "^4.5.0",
45 | "eslint-config-eslint": "^4.0.0",
46 | "mocha": "^3.5.0",
47 | "nyc": "^11.1.0"
48 | },
49 | "engines": {
50 | "node": ">=8.0.0"
51 | },
52 | "scripts": {
53 | "lint": "eslint .",
54 | "fix": "eslint --fix .",
55 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
56 | "test": "egg-bin test",
57 | "cov": "egg-bin cov",
58 | "ci": "npm run lint && npm run cov",
59 | "ii": "npm install --registry https://registry.npmmirror.com"
60 | },
61 | "nyc": {
62 | "exclude": [
63 | "**/*.spec.js",
64 | "test/*.test.js"
65 | ]
66 | },
67 | "ci": {
68 | "version": "10, 12, 14"
69 | },
70 | "repository": {
71 | "type": "git",
72 | "url": "git+https://github.com/ves-team/ves-cli.git"
73 | },
74 | "publishConfig": {
75 | "tag": "next"
76 | },
77 | "bugs": {
78 | "url": "https://github.com/ves-team/ves-cli/issues"
79 | },
80 | "homepage": "https://github.com/ves-team/ves-cli#readme",
81 | "author": "hubcarl@126.com",
82 | "license": "MIT"
83 | }
--------------------------------------------------------------------------------
/packages/cli/ves-cli/test/lib.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const expect = require('chai').expect;
3 | // http://chaijs.com/api/bdd/
4 | describe('lib.test.js', () => {
5 | before(() => {
6 | });
7 |
8 | after(() => {
9 | });
10 |
11 | beforeEach(() => {
12 | });
13 |
14 | afterEach(() => {
15 | });
16 |
17 | describe('#expect lib test', () => {
18 | it('should unit api test', () => {
19 | expect(true).to.be.true;
20 | expect(false).to.be.false;
21 | expect(undefined).to.be.undefined;
22 | expect([1,2,3]).to.have.property(1);
23 | expect(['.js','.jsx','.vue']).to.include.members(['.js','.jsx']);
24 | expect({id: 1, name: 'sky'}).to.include.all.keys(['id', 'name']);
25 | });
26 | });
27 | });
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/.eslintignore:
--------------------------------------------------------------------------------
1 | test/fixtures
2 | coverage
3 | public
4 | test/web
5 | node_modules
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "parserOptions": { "ecmaVersion": 8 },
4 | "rules": {
5 | "default-param-last": "off",
6 | "require-unicode-regexp": "off",
7 | "prefer-regex-literals": "off",
8 | "jsdoc/implements-on-classes": "off",
9 | "padding-line-between-statements": "off",
10 | "no-param-reassign": "off",
11 | "no-unused-vars": "off",
12 | "no-prototype-builtins": "off",
13 | "camelcase":"off",
14 | "func-style": "off",
15 | "jsdoc/require-jsdoc": "off"
16 | }
17 | }
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=javascript
2 | *.css linguist-language=javascript
3 | *.html linguist-language=javascript
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | npm-debug.log
3 | node_modules/
4 | coverage/
5 | .idea/
6 | run/
7 | .DS_Store
8 | *.swp
9 | .vscode
10 | *.iml
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 sky
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.
22 |
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/README.md:
--------------------------------------------------------------------------------
1 | # webpack-tool
2 |
3 | Koa Webpack Dev Server:
4 |
5 | - development mode, start webpack koa server, file memory, hot update.
6 |
7 | - production mode, webpack build file to disk.
8 |
9 | ## Version
10 |
11 | - webpack 5: webpack-tool: 5.x.x
12 | - webpack 4: webpack-tool: 4.x.x
13 | - webpack 3: webpack-tool: 3.x.x
14 |
15 | ## Install
16 |
17 | ```bash
18 | $ npm i webpack-tool --save
19 | ```
20 |
21 | ## Usage
22 |
23 | ```js
24 | //build/index.js
25 | const WebpackTool = require('webpack-tool');
26 | const NODE_ENV = process.env.VIEW;
27 |
28 | const webpackTool = new WebpackTool({
29 | devServer: {
30 | before: before => {
31 | // register koa middleware
32 | },
33 | after: app => {
34 | // register koa middleware
35 | },
36 | proxy: {
37 | '/api': {
38 | target: 'http://localhost:3000',
39 | pathRewrite: {'^/api' : ''}
40 | }
41 | },
42 | historyApiFallback: {
43 | index: '/app.html'
44 | }
45 | }
46 | });
47 |
48 | const webpackConfig = {
49 | entry:{
50 | index: './src/index.js'
51 | },
52 | module:{
53 | rules:[]
54 | }
55 | plugins: []
56 | };
57 |
58 | if (NODE_ENV === 'development') {
59 | // start webpack build and show build result ui view
60 | webpackTool.server(webpackConfig);
61 | } else {
62 | // if you want to show build result ui view for build mode, please set process.env.BUILD_VIEW=true
63 | webpackTool.build(webpackConfig);
64 | }
65 | ```
66 |
67 | ## Configuration
68 |
69 | `config.devServer` support follow option:
70 |
71 | - `proxy` {Object} see https://webpack.docschina.org/configuration/dev-server/#devserver-proxy
72 |
73 | - `historyApiFallback` {Object} see https://webpack.docschina.org/configuration/dev-server/#devserver-historyapifallback
74 |
75 | - `before` {Function} see https://webpack.docschina.org/configuration/dev-server/#devserver-before
76 |
77 | - `after` {Function} see https://webpack.docschina.org/configuration/dev-server/#devserver-after
78 |
79 | ## Run
80 |
81 | ```js
82 | "scripts": {
83 | "start": "cross-env node build"
84 | }
85 | ```
86 |
87 | ```bash
88 | npm start
89 | ```
90 |
91 | Start Webpack Debug Server: http://127.0.0.1:8888/debug
92 |
93 | 
94 |
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/doc/webpack-tool-ui-view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/cli/webpack-tool/doc/webpack-tool-ui-view.png
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = exports = require('./lib/tool');
3 | exports.utils = require('./lib/utils');
4 | exports.webpack = exports.utils.getWebpack();
5 | exports.merge = require('webpack-merge');
6 | exports.KoaWebpackHotMiddleware = require('./lib/hot');
7 | exports.KoaWebpackDevMiddleware = require('./lib/dev');
8 | exports.KoaProxyMiddleware = require('./lib/proxy');
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/lib/dev.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable node/callback-return */
2 | /* eslint-disable prefer-spread */
3 | /* eslint-disable prefer-rest-params */
4 | 'use strict';
5 |
6 | const expressMiddleware = require('webpack-dev-middleware').default;
7 |
8 | function middleware(doIt, req, res) {
9 | const { send: originalSend, end: originalEnd } = res;
10 |
11 | return new Promise(resolve => {
12 | res.end = function end() {
13 | originalEnd.apply(this, arguments);
14 | resolve(0);
15 | };
16 | res.send = function send() {
17 | originalSend.apply(this, arguments);
18 | resolve(0);
19 | };
20 | doIt(req, res, () => {
21 | resolve(1);
22 | });
23 | });
24 | }
25 |
26 | module.exports = (compiler, option) => {
27 | const doIt = expressMiddleware(compiler, option);
28 |
29 | async function koaMiddleware(ctx, next) {
30 | const { req } = ctx;
31 | const locals = ctx.locals || ctx.state;
32 |
33 | ctx.webpack = doIt;
34 |
35 | const runNext = await middleware(doIt, req, {
36 | locals,
37 | end(content) {
38 | ctx.body = content;
39 | },
40 | send(content) {
41 | ctx.body = content;
42 | },
43 | setHeader() {
44 | ctx.set.apply(ctx, arguments);
45 | },
46 | set() {
47 | ctx.set.apply(ctx, arguments);
48 | },
49 | get() {
50 | ctx.get.apply(ctx, arguments);
51 | }
52 | });
53 |
54 | if (runNext) {
55 | await next();
56 | }
57 | }
58 |
59 | Object.keys(doIt).forEach(p => {
60 | koaMiddleware[p] = doIt[p];
61 | });
62 |
63 | return koaMiddleware;
64 | };
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/lib/history.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable node/callback-return */
2 | 'use strict';
3 |
4 | const url = require('url');
5 |
6 | function evaluateRewriteRule(parsedUrl, match, rule) {
7 | if (typeof rule === 'string') {
8 | return rule;
9 | }
10 | if (typeof rule !== 'function') {
11 | throw new Error('Rewrite rule can only be of type string of function.');
12 | }
13 |
14 | return rule({
15 | parsedUrl,
16 | match
17 | });
18 | }
19 |
20 | function acceptsHtml(header) {
21 | return header.indexOf('text/html') !== -1 || header.indexOf('*/*') !== -1;
22 | }
23 |
24 | function getLogger(options) {
25 | if (options && options.logger) {
26 | return options.logger;
27 | }
28 | if (options && options.verbose) {
29 | return console.log.bind(console);
30 | }
31 | return function() { };
32 | }
33 |
34 | module.exports = function koaFallbackApiMiddleware(options) {
35 | options = options || {};
36 | const logger = getLogger(options);
37 |
38 | return async function(ctx, next) {
39 | const headers = ctx.headers,
40 | reqUrl = ctx.url,
41 | method = ctx.method;
42 |
43 | if (ctx.method !== 'GET') {
44 | logger(
45 | 'Not rewriting',
46 | method,
47 | reqUrl,
48 | 'because the method is not GET.'
49 | );
50 | return await next();
51 | }
52 | if (!headers || typeof headers.accept !== 'string') {
53 | logger(
54 | 'Not rewriting',
55 | method,
56 | reqUrl,
57 | 'because the client did not send an HTTP accept header.'
58 | );
59 | return await next();
60 | }
61 | if (headers.accept.indexOf('application/json') === 0) {
62 | logger(
63 | 'Not rewriting',
64 | method,
65 | reqUrl,
66 | 'because the client prefers JSON.'
67 | );
68 | return await next();
69 | }
70 | if (!acceptsHtml(headers.accept)) {
71 | logger(
72 | 'Not rewriting',
73 | method,
74 | reqUrl,
75 | 'because the client does not accept HTML.'
76 | );
77 | return await next();
78 | }
79 |
80 | // eslint-disable-next-line node/no-deprecated-api
81 | const parsedUrl = url.parse(reqUrl);
82 | let rewriteTarget;
83 |
84 | options.rewrites = options.rewrites || [];
85 |
86 | for (let i = 0; i < options.rewrites.length; i++) {
87 | const rewrite = options.rewrites[i];
88 | const match = parsedUrl.pathname.match(rewrite.from);
89 | if (match !== null) {
90 | rewriteTarget = evaluateRewriteRule(parsedUrl, match, rewrite.to);
91 | logger('Rewriting', method, reqUrl, 'to', rewriteTarget);
92 | ctx.url = rewriteTarget;
93 | return await next();
94 | }
95 | }
96 |
97 | if (parsedUrl.pathname.indexOf('.') !== -1) {
98 | logger(
99 | 'Not rewriting',
100 | method,
101 | reqUrl,
102 | 'because the path includes a dot (.) character.'
103 | );
104 | return await next();
105 | }
106 |
107 | rewriteTarget = options.index || '/index.html';
108 | logger('Rewriting', method, reqUrl, 'to', rewriteTarget);
109 | ctx.url = rewriteTarget;
110 |
111 | await next();
112 | };
113 | };
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/lib/hot.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable node/callback-return */
2 | /* eslint-disable prefer-rest-params */
3 | 'use strict';
4 | const webpackHotMiddleware = require('webpack-hot-middleware');
5 |
6 | function middleware(doIt, req, res) {
7 | const { send: originalSend, end: originalEnd } = res;
8 |
9 | return new Promise(resolve => {
10 | res.end = function end() {
11 | originalEnd.apply(this, arguments);
12 | resolve(0);
13 | };
14 | res.send = function send() {
15 | originalSend.apply(this, arguments);
16 | resolve(0);
17 | };
18 | doIt(req, res, () => {
19 | resolve(1);
20 | });
21 | });
22 | }
23 |
24 | module.exports = function(compiler, option) {
25 | const action = webpackHotMiddleware(compiler, option);
26 | return async function(ctx, next) {
27 | const nextStep = await middleware(action, ctx.req, ctx.res);
28 | if (nextStep && next) {
29 | await next();
30 | }
31 | };
32 | };
33 |
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/lib/nav.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const artTemplate = require('art-template');
4 | const easyHelper = require('easy-helper');
5 | const utils = require('./utils');
6 |
7 | class NavigationPage {
8 | constructor(config, compiler, stat) {
9 | this.config = config;
10 | this.compiler = compiler;
11 | this.stat = stat;
12 | }
13 |
14 | getName() {
15 | const modules = this.stat.compilation.modules;
16 | const target = this.compiler.options.target;
17 |
18 | if (target === 'node') {
19 | return 'Server';
20 | }
21 | const isWeex = modules.some(m => /weex-vue-loader/.test(m.request));
22 |
23 | if (isWeex) {
24 | return 'Weex';
25 | }
26 | return 'Web';
27 | }
28 |
29 | normalizePublicPath(publicPath, port) {
30 | if (/https?:/.test(publicPath)) {
31 | return publicPath.replace(/:\d{2,6}\//, `:${port}/`);
32 | }
33 | const ip = utils.getIp(2);
34 |
35 | return `http://${ip}:${port}/${publicPath.replace(/^\//, '')}`;
36 | }
37 |
38 | filterFile(files, htmls) {
39 | if (htmls.length) {
40 | return htmls.sort().filter(url => {
41 | return /\.(html|htm|tpl)$/.test(url);
42 | });
43 | }
44 | return files.filter(filename => {
45 | return !/\.hot-update\.(js|json)$/.test(filename) && /\.js$/.test(filename);
46 | }).sort();
47 | }
48 |
49 | resolve() {
50 | const webpackConfig = this.compiler.options;
51 | const easyInfo = easyHelper.getEasyInfo();
52 | const target = webpackConfig.target || 'web';
53 | const port = easyInfo[target].port || this.config.port - 1;
54 | const publicPath = this.normalizePublicPath(webpackConfig.output.publicPath, port);
55 | const assets = Object.keys(this.stat.compilation.assets).sort().map(name => {
56 | const url = `${publicPath.replace(/\/$/, '')}/${name.replace(/^\//, '')}`;
57 |
58 | return {
59 | name,
60 | url
61 | };
62 | });
63 | const name = this.getName();
64 | const html = assets.filter(item => {
65 | return /\.(html|htm|tpl)$/.test(item.name);
66 | });
67 | const js = assets.filter(item => {
68 | return !/\.hot-update\.(js|json)$/.test(item.name) && /\.js$/.test(item.name);
69 | });
70 | const files = html.length > 0 ? html : js;
71 |
72 | return { name, files, html, js };
73 | }
74 |
75 | create() {
76 | const item = this.resolve();
77 |
78 | return artTemplate(path.join(__dirname, 'view.html'), {
79 | result: [item]
80 | });
81 | }
82 | }
83 |
84 | module.exports = NavigationPage;
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/lib/proxy.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable node/callback-return */
2 | 'use strict';
3 | const c2k = require('koa2-connect');
4 | const proxyMiddleware = require('http-proxy-middleware');
5 |
6 | module.exports = function(proxyUrl, proxyOptions) {
7 | // 新功能,前端项目支持 pathRewrite
8 | if (proxyOptions && proxyOptions.pathRewrite) {
9 | return async function(ctx, next) {
10 | if (new RegExp(proxyUrl).test(ctx.url)) {
11 | await c2k(proxyMiddleware(proxyOptions));
12 | } else {
13 | await next();
14 | }
15 | };
16 | }
17 | // 先保留之前的实现保证稳定性
18 | const proxy = require('http-proxy').createProxyServer(proxyOptions);
19 | return async function(ctx, next) {
20 | if (new RegExp(proxyUrl).test(ctx.url)) {
21 | await function(callback) {
22 | proxy.web(ctx.req, ctx.res, callback);
23 | };
24 | } else {
25 | await next();
26 | }
27 | };
28 | };
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/lib/view.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Webpack 编译文件导航
6 |
7 |
8 |
9 |
10 |
11 |
66 |
67 |
68 |
71 |
72 |
73 | {{each result}}
74 |
{{$value.name}}
75 |
76 | {{each $value.files item}}
77 | - {{item.name}}
78 | {{/each}}
79 |
80 |
81 | {{/each}}
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "webpack-tool",
3 | "version": "5.0.3",
4 | "description": "webpack build and webpack build result web view",
5 | "keywords": [
6 | "webpack",
7 | "webpack3",
8 | "webpack4",
9 | "webpack build",
10 | "webpack hot reload"
11 | ],
12 | "dependencies": {
13 | "art-template": "^4.11.0",
14 | "chalk": "^4.1.0",
15 | "detect-port": "^1.2.3",
16 | "easy-helper": "^1.0.2",
17 | "http-proxy": "^1.17.0",
18 | "http-proxy-middleware": "^1.0.5",
19 | "kcors": "^2.2.2",
20 | "koa": "^2.13.0",
21 | "koa2-connect": "^1.0.2",
22 | "node-tool-utils": "^1.0.0",
23 | "opn": "^6.0.0",
24 | "webpack": "^5.0.0",
25 | "webpack-dev-middleware": "4.0.0-rc.3",
26 | "webpack-hot-middleware": "^2.25.0",
27 | "webpack-merge": "^4.0.0"
28 | },
29 | "devDependencies": {
30 | "conventional-changelog-cli": "^2.1.0",
31 | "eslint": "^7.8.1",
32 | "eslint-config-eslint": "^6.0.0",
33 | "mocha": "^8.2.0"
34 | },
35 | "engines": {
36 | "node": ">=10.0.0"
37 | },
38 | "scripts": {
39 | "lint": "eslint .",
40 | "fix": "eslint --fix .",
41 | "test": "mocha test",
42 | "ci": "npm run lint && npm run cov",
43 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
44 | },
45 | "files": [
46 | "index.js",
47 | "utils",
48 | "lib",
49 | "tool"
50 | ],
51 | "ci": {
52 | "version": "10, 12, 14"
53 | },
54 | "repository": {
55 | "type": "git",
56 | "url": "git+https://github.com/easy-team/webpack-tool.git"
57 | },
58 | "publishConfig": {
59 | "tag": "5x"
60 | },
61 | "bugs": {
62 | "url": "https://github.com/easy-team/webpack-tool/issues"
63 | },
64 | "homepage": "https://github.com/easy-team/webpack-tool#readme",
65 | "author": "hubcarl@126.com",
66 | "license": "MIT"
67 | }
68 |
--------------------------------------------------------------------------------
/packages/cli/webpack-tool/test/index.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/cli/webpack-tool/test/index.js
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/.eslintignore:
--------------------------------------------------------------------------------
1 | test/fixtures
2 | coverage
3 | public
4 | test/web
5 | node_modules
6 | example
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "rules": {
4 | "default-param-last": "off",
5 | "require-unicode-regexp": "off",
6 | "prefer-regex-literals": "off",
7 | "jsdoc/implements-on-classes": "off"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=javascript
2 | *.css linguist-language=javascript
3 | *.html linguist-language=javascript
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | npm-debug.log
3 | node_modules/
4 | coverage/
5 | .idea/
6 | run/
7 | .DS_Store
8 | *.swp
9 | .vscode
10 | *.iml
11 | public/
12 | config/manifest.json
13 | package-lock.json
14 | yarn.lock
15 | coverage.lcov
16 | .nyc_output
17 | example/*/test/dist
18 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '6'
5 | - '8'
6 | - '9'
7 | script:
8 | - npm test
9 | after_success:
10 | - npm run cov
11 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # [4.0.0](https://github.com/hubcarl/easywebpack-js/compare/4.0.2...4.0.0) (2019-11-29)
2 |
3 |
4 | ### Features
5 |
6 | * easy-team mode ([6db50b1](https://github.com/hubcarl/easywebpack-js/commit/6db50b1))
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 sky
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.
22 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/config/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | buildPath: 'dist',
3 | hot: false,
4 | hash: false,
5 | loaders:{
6 | scss: false,
7 | sass: false,
8 | less: false,
9 | stylus: false
10 | },
11 | plugins: {
12 | manifest: false,
13 | manifestDeps: false,
14 | imagemini: false,
15 | commonsChunk: false
16 | }
17 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/doc/images/react-lib.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/framework/easywebpack-js/doc/images/react-lib.png
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/doc/images/vue-lib.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/framework/easywebpack-js/doc/images/vue-lib.png
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/react-common-lib/README.md:
--------------------------------------------------------------------------------
1 | # easy-react-common-lib
2 |
3 | React Project Common Lib, Support Debug, Release, Polyfill Lib.
4 |
5 | ## Usage
6 |
7 | ### Building React Common Lib
8 |
9 | ```bash
10 | npm run build
11 | ```
12 |
13 |
14 | ### Building React Common Polyfill Lib
15 |
16 | ```bash
17 | npm run build:polyfill
18 | ```
19 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/react-common-lib/babel.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const POLYFILL = /polyfill/.test(process.env.SCRIPT_TAG);
3 | const presetEnv = POLYFILL ? {
4 | modules: false,
5 | debug: true,
6 | useBuiltIns: 'usage',
7 | corejs: { version: 3, proposals: true },
8 | targets: {
9 | browsers: ['Android >= 4']
10 | }
11 | } : {
12 | modules: false,
13 | debug: true,
14 | useBuiltIns: false
15 | };
16 | console.log('>>POLYFILL', POLYFILL);
17 | module.exports = {
18 | presets: [
19 | '@babel/preset-react',
20 | ['@babel/preset-env', presetEnv]
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/react-common-lib/lib/react-mobx.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import React from 'react';
4 | import ReactDOM from 'react-dom';
5 | import * as MobX from 'mobx';
6 | import * as ReactMobX from 'mobx-react';
7 |
8 | // window.React = React;
9 | // window.ReactDOM = ReactDOM;
10 | // window.MobX = MobX;
11 | // window.ReactMobX = ReactMobX;
12 |
13 | export default {
14 | React,
15 | ReactDOM,
16 | MobX,
17 | ReactMobX
18 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/react-common-lib/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "easy-react-common-lib",
3 | "version": "1.0.0",
4 | "description": "React Project Common Lib",
5 | "scripts": {
6 | "start": "npm run build",
7 | "debug": "SCRIPT_TAG=debug easy build test",
8 | "build": "SCRIPT_TAG=min easy build prod",
9 | "release": "easy clean && npm run debug && npm run build",
10 | "debug:polyfill": "SCRIPT_TAG=polyfill.debug easy build test",
11 | "build:polyfill": "SCRIPT_TAG=polyfill.min easy build prod",
12 | "release:polyfill": "easy clean && npm run debug:polyfill && npm run build:polyfill",
13 | "lint": "eslint .",
14 | "fix": "eslint --fix .",
15 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
16 | },
17 | "dependencies": {
18 | "mobx": "^5.14.0",
19 | "mobx-react": "^6.1.3",
20 | "react": "^16.8.2",
21 | "react-dom": "^16.8.2",
22 | "react-mobx": "^0.0.4",
23 | "react-redux": "^6.0.1",
24 | "redux": "^4.0.1",
25 | "redux-thunk": "^2.3.0",
26 | "core-js": "^3.4.5"
27 | },
28 | "devDependencies": {
29 | "@babel/preset-react": "^7.7.4",
30 | "@easy-team/easywebpack-cli": "^4.0.0",
31 | "@easy-team/easywebpack-js": "4.0.0",
32 | "chai": "^4.1.1",
33 | "codecov": "^3.0.0",
34 | "conventional-changelog-cli": "^1.3.5",
35 | "cross-env": "^5.0.5",
36 | "eslint": "^4.5.0",
37 | "eslint-config-eslint": "^4.0.0",
38 | "mocha": "^3.5.0",
39 | "nyc": "^11.1.0",
40 | "react-hot-loader": "^4.12.18"
41 | },
42 | "keywords": [
43 | "react",
44 | "mobx",
45 | "redux"
46 | ],
47 | "nyc": {
48 | "exclude": [
49 | "**/*.spec.js",
50 | "test/*.test.js"
51 | ]
52 | },
53 | "ci": {
54 | "version": "8, 10, 12"
55 | },
56 | "repository": {
57 | "type": "git",
58 | "url": "git+http://github.com/easy-team/easy-react-common-lib.git"
59 | },
60 | "homepage": "http://github.com/easy-team/easy-react-common-lib#readme",
61 | "author": "hubcarl@126.com"
62 | }
63 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/react-common-lib/test/babel.config.js:
--------------------------------------------------------------------------------
1 | 'use script';
2 | module.exports = {
3 | 'presets': [
4 | '@babel/preset-react',
5 | ['@babel/preset-env', {
6 | 'modules': false,
7 | // 'debug': true,
8 | 'useBuiltIns': false
9 | }]
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/react-common-lib/test/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "easy-react-common-lib-test",
3 | "version": "1.0.0",
4 | "description": "React Project Common Lib Test",
5 | "scripts": {
6 | "dev": "easy clean && easy dev",
7 | "start": "easy build --server",
8 | "test": "easy build test",
9 | "build": "easy build prod",
10 | "deploy": "easy build prod",
11 | "lint": "eslint .",
12 | "fix": "eslint --fix .",
13 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
14 | },
15 | "dependencies": {},
16 | "devDependencies": {
17 | "cross-env": "^5.0.5",
18 | "@easy-team/easywebpack-cli": "^4.0.0",
19 | "@easy-team/easywebpack-react": "^4.0.0",
20 | "imagemin-webpack-plugin": "^2.4.2"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/react-common-lib/test/src/react-mobx.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import ReactDOM from 'react-dom';
3 | import { AppContainer } from 'react-hot-loader';
4 |
5 | class App extends Component {
6 | render() {
7 | return React MobX Common Lib Test
8 | }
9 | }
10 |
11 |
12 | ReactDOM.render(
13 | EASY_ENV_IS_DEV ? : ,
14 | document.getElementById('app')
15 | );
16 | if (module.hot) {
17 | module.hot.accept();
18 | }
19 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/react-common-lib/test/src/view/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | React Common Lib Test
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/react-common-lib/test/webpack.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const resolve = filepath => path.resolve(__dirname, filepath);
4 |
5 | module.exports = {
6 | framework: 'react',
7 | entry: {
8 | 'react-mobx': 'src/react-mobx.js'
9 | },
10 | externals: {
11 | 'react': 'ReactMobxLib.default.React',
12 | 'react-dom': 'ReactMobxLib.default.ReactDOM',
13 | 'mobx': 'ReactMobxLib.default.MobX',
14 | 'mobx-react': 'ReactMobxLib.default.ReactMobX'
15 | },
16 | plugins: [
17 | {
18 | copy: [{
19 | from: resolve('../dist'),
20 | to: resolve('dist')
21 | }]
22 | }
23 | ]
24 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/react-common-lib/webpack.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const pkg = require('./package.json');
3 | const version = pkg.version;
4 | const SCRIPT_TAG = process.env.SCRIPT_TAG;
5 | module.exports = {
6 | framework: 'js',
7 | entry: {
8 | [`react-mobx-lib-${version}.${SCRIPT_TAG}`] : 'lib/react-mobx.js',
9 | },
10 | output: {
11 | library: 'ReactMobxLib'
12 | },
13 | plugins:[
14 | {
15 | clean: false
16 | }
17 | ]
18 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/vue-common-lib/README.md:
--------------------------------------------------------------------------------
1 | # vue-common-lib
2 |
3 | Vue Project Common Lib, Support Debug, Release, Polyfill Lib.
4 |
5 | ## Usage
6 |
7 | ### Building Vue Common Lib
8 |
9 | ```bash
10 | npm run build
11 | ```
12 |
13 |
14 | ### Building Vue Common Polyfill Lib
15 |
16 | ```bash
17 | npm run build:polyfill
18 | ```
19 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/vue-common-lib/babel.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const POLYFILL = /polyfill/.test(process.env.SCRIPT_TAG);
3 | const presetEnv = POLYFILL ? {
4 | modules: false,
5 | debug: true,
6 | useBuiltIns: 'usage',
7 | corejs: { version: 3, proposals: true },
8 | targets: {
9 | browsers: ['Android >= 4']
10 | }
11 | } : {
12 | modules: false,
13 | debug: true,
14 | useBuiltIns: false
15 | };
16 | console.log('>>POLYFILL', POLYFILL);
17 | module.exports = {
18 | presets: [
19 | ['@babel/preset-env', presetEnv]
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/vue-common-lib/lib/vue-lib.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import Vue from 'vue';
4 | import Vuex from 'vuex';
5 | import VueRouter from 'vue-router';
6 |
7 | // window.Vue = Vue;
8 | // window.Vuex = Vuex;
9 | // window.VueRouter = VueRouter;
10 |
11 | export default {
12 | Vue,
13 | Vuex,
14 | VueRouter
15 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/vue-common-lib/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-common-lib",
3 | "version": "1.0.0",
4 | "description": "Vue Project Common Lib",
5 | "scripts": {
6 | "start": "npm run build",
7 | "debug": "SCRIPT_TAG=debug easy build test",
8 | "build": "SCRIPT_TAG=min easy build prod",
9 | "release": "easy clean && npm run debug && npm run build",
10 | "debug:polyfill": "SCRIPT_TAG=polyfill.debug easy build test",
11 | "build:polyfill": "SCRIPT_TAG=polyfill.min easy build prod",
12 | "release:polyfill": "easy clean && npm run debug:polyfill && npm run build:polyfill",
13 | "lint": "eslint .",
14 | "fix": "eslint --fix .",
15 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
16 | },
17 | "dependencies": {
18 | "vue": "^2.5.0",
19 | "vue-router": "^3.0.1",
20 | "vuex": "^3.0.1",
21 | "vuex-router-sync": "^5.0.0"
22 | },
23 | "devDependencies": {
24 | "@easy-team/easywebpack-cli": "^4.0.0",
25 | "@easy-team/easywebpack-js": "4.0.0",
26 | "chai": "^4.1.1",
27 | "codecov": "^3.0.0",
28 | "conventional-changelog-cli": "^1.3.5",
29 | "cross-env": "^5.0.5",
30 | "eslint": "^4.5.0",
31 | "eslint-config-eslint": "^4.0.0",
32 | "mocha": "^3.5.0",
33 | "nyc": "^11.1.0"
34 | },
35 | "keywords": [
36 | "vue",
37 | "vuex",
38 | "vue-router"
39 | ],
40 | "nyc": {
41 | "exclude": [
42 | "**/*.spec.js",
43 | "test/*.test.js"
44 | ]
45 | },
46 | "ci": {
47 | "version": "8, 10, 12"
48 | },
49 | "repository": {
50 | "type": "git",
51 | "url": "git+http://github.com/easy-team/easywebpack-js.git"
52 | },
53 | "homepage": "http://github.com/easy-team/easywebpack-js#readme",
54 | "author": "hubcarl@126.com"
55 | }
56 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/vue-common-lib/test/babel.config.js:
--------------------------------------------------------------------------------
1 | 'use script';
2 | module.exports = {
3 | 'presets': [
4 | ['@babel/preset-env', {
5 | 'modules': false,
6 | // 'debug': true,
7 | 'useBuiltIns': false
8 | }]
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/vue-common-lib/test/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "easy-vue-common-lib-test",
3 | "version": "1.0.0",
4 | "description": "Vue Project Common Lib Test",
5 | "scripts": {
6 | "dev": "easy clean && easy dev",
7 | "start": "easy build --server",
8 | "test": "easy build test",
9 | "build": "easy build prod",
10 | "deploy": "easy build prod",
11 | "lint": "eslint .",
12 | "fix": "eslint --fix .",
13 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
14 | },
15 | "dependencies": {},
16 | "devDependencies": {
17 | "@easy-team/easywebpack-cli": "^4.0.0",
18 | "@easy-team/easywebpack-vue": "^4.0.0",
19 | "cross-env": "^5.0.5",
20 | "imagemin-webpack-plugin": "^2.4.2",
21 | "vue-template-compiler": "^2.6.10"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/vue-common-lib/test/src/app.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import VueRouter from 'vue-router';
3 |
4 | Vue.use(VueRouter);
5 |
6 | const Foo = { template: 'foo
' }
7 | const Bar = { template: 'bar
' }
8 |
9 | // 2. 定义路由
10 | // 每个路由应该映射一个组件。 其中"component" 可以是
11 | // 通过 Vue.extend() 创建的组件构造器,
12 | // 或者,只是一个组件配置对象。
13 | // 我们晚点再讨论嵌套路由。
14 | const routes = [
15 | { path: '/foo', component: Foo },
16 | { path: '/bar', component: Bar }
17 | ]
18 |
19 | // 3. 创建 router 实例,然后传 `routes` 配置
20 | // 你还可以传别的配置参数, 不过先这么简单着吧。
21 | const router = new VueRouter({
22 | routes // (缩写) 相当于 routes: routes
23 | })
24 |
25 | const app = new Vue({ router }).$mount('#app')
26 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/vue-common-lib/test/src/view/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Vue Common Lib Test
7 |
8 |
9 |
10 |
11 |
Hello App!
12 |
13 |
14 |
15 |
16 | Go to Foo
17 | Go to Bar
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/vue-common-lib/test/webpack.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const resolve = filepath => path.resolve(__dirname, filepath);
4 |
5 | module.exports = {
6 | framework: 'vue',
7 | entry: {
8 | app: 'src/app.js'
9 | },
10 | externals: {
11 | 'vue': 'VueLib.default.Vue',
12 | 'vuex': 'VueLib.default.Vuex',
13 | 'vue-router': 'VueLib.default.VueRouter'
14 | },
15 | plugins: [
16 | {
17 | copy: [{
18 | from: resolve('../dist'),
19 | to: resolve('dist')
20 | }]
21 | }
22 | ]
23 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/example/vue-common-lib/webpack.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const pkg = require('./package.json');
3 | const version = pkg.version;
4 | const SCRIPT_TAG = process.env.SCRIPT_TAG;
5 | module.exports = {
6 | framework: 'js',
7 | entry: {
8 | [`vue-lib-${version}.${SCRIPT_TAG}`] : 'lib/vue-lib.js',
9 | },
10 | output: {
11 | library: 'VueLib'
12 | },
13 | resolve: {
14 | alias: {
15 | 'vue$': 'vue/dist/vue.esm.js'
16 | }
17 | },
18 | plugins:[
19 | {
20 | clean: false
21 | }
22 | ]
23 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const EasyWebpack = require('easywebpack');
3 | exports.EasyWebpack = EasyWebpack;
4 | Object.assign(exports, EasyWebpack);
5 | exports.WebpackClientBuilder = require('./lib/client');
6 | exports.getWebpackConfig = (config, option) => {
7 | return EasyWebpack.WebpackBuilder.getWebpackConfig(config, [exports.WebpackClientBuilder], option);
8 | };
9 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/lib/client.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const EasyWebpack = require('easywebpack');
4 | class WebpackClientBuilder extends EasyWebpack.WebpackClientBuilder {
5 | constructor(config) {
6 | super(config);
7 | this.mergeConfig(require('../config/config'));
8 | this.setLibraryTarget('umd');
9 | this.setResolveLoader({ modules: [path.join(__dirname, '../node_modules')] });
10 | }
11 |
12 | createFileName() {
13 | this.setOutputFileName('[name].js');
14 | this.setOutputFileChunkName('[name].chunk.js');
15 | }
16 |
17 | createImageName() {
18 | this.webpackInfo.imageName = 'img/[name].[ext]';
19 | }
20 |
21 | createCssName() {
22 | this.webpackInfo.cssName = 'css/[name].css';
23 | }
24 |
25 | createFrontName() {
26 | this.webpackInfo.frontName = 'font/[name].[ext]';
27 | }
28 |
29 | createOptimization() {
30 | return this.webpackOptimize.getOptimization();
31 | }
32 | }
33 | module.exports = WebpackClientBuilder;
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "easywebpack-js",
3 | "version": "5.0.0",
4 | "description": "Webpack Javascript Lib Building for easywebpack",
5 | "keywords": [
6 | "webpack",
7 | "easywebpack",
8 | "compress js",
9 | "ugilyfy js"
10 | ],
11 | "dependencies": {
12 | "easywebpack": "^5.0.0",
13 | "cross-env": "^5.0.1"
14 | },
15 | "devDependencies": {
16 | "chai": "^4.0.0",
17 | "codecov": "^3.6.5",
18 | "conventional-changelog-cli": "^1.3.5",
19 | "coveralls": "^2.13.1",
20 | "eslint": "^4.6.1",
21 | "mocha": "^3.4.2",
22 | "nyc": "^11.1.0"
23 | },
24 | "engines": {
25 | "node": ">=8.0.0"
26 | },
27 | "scripts": {
28 | "lint": "eslint .",
29 | "fix": "eslint --fix .",
30 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
31 | "test": "nyc --reporter=html --reporter=text mocha --timeout=1000000",
32 | "cov": "nyc report --reporter=lcov > coverage.lcov && codecov --token=f094144f-fb4f-477e-8c87-90cdef9bbddd",
33 | "ii": "yarn --registry https://registry.npmmirror.com"
34 | },
35 | "files": [
36 | "index.js",
37 | "lib",
38 | "config",
39 | "tool"
40 | ],
41 | "ci": {
42 | "version": "8, 10, 12, 14"
43 | },
44 | "repository": {
45 | "type": "git",
46 | "url": "git+https://github.com/hubcarl/easywebpack-js.git"
47 | },
48 | "bugs": {
49 | "url": "https://github.com/hubcarl/easywebpack-js/issues"
50 | },
51 | "homepage": "https://github.com/hubcarl/easywebpack-js#readme",
52 | "author": "hubcarl@126.com",
53 | "license": "MIT"
54 | }
55 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-js/test/client.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const expect = require('chai').expect;
3 | const WebpackClientBuilder = require('../lib/client');
4 | const path = require('path');
5 |
6 | describe('client.test.js', () => {
7 | before(() => {
8 | });
9 |
10 | after(() => {
11 | });
12 |
13 | beforeEach(() => {
14 | });
15 |
16 | afterEach(() => {
17 | });
18 |
19 | describe('#webpack js config test', () => {
20 | it('should output default test', () => {
21 | const builder = new WebpackClientBuilder({
22 | entry: {
23 | 'index': 'lib/client.js'
24 | }
25 | });
26 | const webpackConfig = builder.create();
27 | expect(webpackConfig.entry).to.have.keys(['index']);
28 | expect(webpackConfig.output.path).to.equal(path.join(process.cwd(), 'dist'));
29 | expect(webpackConfig.output.filename).to.equal('[name].js');
30 | expect(webpackConfig.output.chunkFilename).to.equal('[name].chunk.js');
31 | });
32 |
33 | it('should env prod test', () => {
34 | const builder = new WebpackClientBuilder({
35 | env: 'prod',
36 | entry: {
37 | 'index': 'lib/client.js'
38 | }
39 | });
40 | const webpackConfig = builder.create();
41 | expect(webpackConfig.entry).to.have.keys(['index']);
42 | expect(webpackConfig.mode).to.equal('production');
43 | expect(webpackConfig.optimization.minimizer.length).to.equal(2);
44 | });
45 | });
46 | });
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/.eslintignore:
--------------------------------------------------------------------------------
1 | test/fixtures
2 | coverage
3 | public
4 | test/web
5 | node_modules
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "parserOptions": { "ecmaVersion": 8 },
4 | "rules": {
5 | "default-param-last": "off",
6 | "require-unicode-regexp": "off",
7 | "prefer-regex-literals": "off",
8 | "jsdoc/implements-on-classes": "off",
9 | "padding-line-between-statements": "off",
10 | "no-param-reassign": "off",
11 | "no-unused-vars": "off",
12 | "no-prototype-builtins": "off",
13 | "camelcase":"off",
14 | "func-style": "off",
15 | "jsdoc/require-jsdoc": "off"
16 | }
17 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=javascript
2 | *.css linguist-language=javascript
3 | *.html linguist-language=javascript
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | npm-debug.log
3 | node_modules/
4 | coverage/
5 | .idea/
6 | run/
7 | .DS_Store
8 | *.swp
9 | .vscode
10 | *.iml
11 | dist
12 | public/
13 | config/buildConfig.json
14 | config/manifest.json
15 | package-lock.json
16 | .nyc_output
17 | package-lock.json
18 | yarn.lock
19 |
20 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '6'
5 | - '8'
6 | - '9'
7 | script:
8 | - npm test
9 | after_success:
10 | - npm run cov
11 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 sky
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.
22 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/config/babel.node.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = {
3 | presets: [
4 | '@babel/preset-react',
5 | ['@babel/preset-env', {
6 | modules: false,
7 | targets: {
8 | node: 'current'
9 | }
10 | }]
11 | ]
12 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/config/babel.web.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = {
3 | presets: [
4 | '@babel/preset-react',
5 | ['@babel/preset-env', {
6 | modules: false,
7 | targets: {
8 | browsers: ['last 2 versions', '> 1%', 'Android >= 4.0', 'ios >= 9']
9 | }
10 | }]
11 | ],
12 | plugins: [
13 | ['@babel/plugin-proposal-decorators', { legacy: true }],
14 | ['@babel/plugin-proposal-class-properties', { loose: true }],
15 | '@babel/plugin-proposal-async-generator-functions',
16 | '@babel/plugin-proposal-object-rest-spread',
17 | '@babel/plugin-transform-object-assign',
18 | '@babel/plugin-syntax-dynamic-import',
19 | '@babel/plugin-transform-runtime'
20 | ],
21 | comments: false
22 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = {
3 | hotCss: true
4 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/config/plugin.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const ReactSSRDynamicChunkPlugin = require('./plugin/react-ssr-dynamic-chunk-webpack-plugin');
3 | exports.reactssrchunk = {
4 | type: ['server'],
5 | name: new ReactSSRDynamicChunkPlugin(),
6 | args: {
7 | }
8 | };
9 |
10 | exports.extract = {
11 | env: ['dev', 'test', 'prod']
12 | };
13 |
14 | exports.modulereplacement = false;
15 |
16 | exports.ignore = false;
17 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/config/plugin/react-ssr-dynamic-chunk-webpack-plugin/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const fs = require('fs');
4 | const mkdirp = require('mkdirp');
5 |
6 | class ReactSSRDynamicChunkPlugin {
7 | constructor(opts) {
8 | this.opts = Object.assign({ }, { chunk: true }, opts);
9 | }
10 |
11 | apply(compiler) {
12 | compiler.hooks.emit.tap('ReactSSRDynamicChunkPlugin', (compilation, callback) => {
13 | const buildPath = compilation.options.output.path;
14 |
15 |
16 | [...compilation.chunks].forEach(chunk => {
17 | if (!this.opts.chunk) {
18 | return;
19 | }
20 |
21 | const chunks = [ ...chunk.files];
22 | const asyncChunks = [ ...chunk.getAllAsyncChunks()];
23 | const mainChunkFile = chunks.length > 0 ? chunks[0] : null;
24 | const mainChunkDir = mainChunkFile ? path.dirname(mainChunkFile) : null;
25 | asyncChunks && asyncChunks.forEach(asyncChunk => {
26 | asyncChunk.files.forEach(filename => {
27 | const filepath = mainChunkDir ? path.join(buildPath, mainChunkDir, filename) : path.join(buildPath, filename);
28 | const filedir = path.dirname(filepath);
29 | if (!fs.existsSync(filedir)) {
30 | mkdirp.sync(filedir);
31 | }
32 | const source = compilation.assets[filename].source();
33 | fs.writeFileSync(filepath, source, 'utf8');
34 | });
35 | });
36 | });
37 | callback && callback();
38 | });
39 | }
40 | }
41 |
42 | module.exports = ReactSSRDynamicChunkPlugin;
43 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const EasyWebpack = require('easywebpack');
3 | exports.EasyWebpack = EasyWebpack;
4 | Object.assign(exports, EasyWebpack);
5 | exports.WebpackClientBuilder = require('./lib/client');
6 | exports.WebpackServerBuilder = require('./lib/server');
7 | exports.getWebpackConfig = (config, option) => {
8 | return EasyWebpack.WebpackBuilder.getWebpackConfig(config, [exports.WebpackClientBuilder, exports.WebpackServerBuilder], option);
9 | };
10 | exports.getWebWebpackConfig = (config = {}, option = {}) => {
11 | return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackClientBuilder], option);
12 | };
13 |
14 | exports.getNodeWebpackConfig = (config = {}, option = {}) => {
15 | return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackServerBuilder], option);
16 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/lib/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const WebpackReactBaseBuilder = WebpackBuilder => class extends WebpackBuilder {
4 | constructor(config = {}) {
5 | super(config);
6 | this.mergeConfig(require('../config/config'));
7 | this.mergePlugin(require('../config/plugin'));
8 | this.setResolveLoader({
9 | modules: [path.resolve(__dirname, '../node_modules')]
10 | });
11 | this.setBabelrc(path.resolve(__dirname, '../config/.babelrc'));
12 | this.setExtensions('.jsx', false);
13 | if (this.typescript) {
14 | this.setExtensions('.tsx', false);
15 | }
16 | }
17 |
18 | prepareCssModuleLoader(loaders) {
19 | const cssModule = this.config.cssModule;
20 | const cssLoaderName = 'css-loader';
21 | Object.keys(loaders).forEach(name => {
22 | const itemLoader = loaders[name];
23 | if (Array.isArray(itemLoader.use)) {
24 | const cssLoaderIndex = itemLoader.use.findIndex(loader => {
25 | return loader === cssLoaderName || (this.utils.isObject(loader) && loader.loader === cssLoaderName);
26 | });
27 | if (cssLoaderIndex > -1) {
28 | const cssModuleLoader = this.utils.cloneDeep(itemLoader);
29 | const cssModuleName = `${name}_module`;
30 | const cssModuleLoaderOption = this.merge({
31 | options: {
32 | modules: true,
33 | importLoaders: cssModuleLoader.use.length - cssLoaderIndex
34 | }
35 | }, this.utils.isObject(cssModule) && cssModule.options);
36 | const oldCssLoader = cssModuleLoader.use[cssLoaderIndex];
37 | const newCssLoader = this.merge(this.utils.isString(oldCssLoader) ? { loader: cssLoaderName } : oldCssLoader, cssModuleLoaderOption);
38 | cssModuleLoader.use[cssLoaderIndex] = newCssLoader;
39 | if (this.ssr) {
40 | cssModuleLoader.use.unshift('isomorphic-style-loader');
41 | }
42 | // config.cssModule 模式
43 | if (cssModule) {
44 | if (this.utils.isObject(cssModule) && cssModule.include) {
45 | const include = [].concat(cssModule.include).map(filepath => {
46 | return this.utils.normalizePath(filepath, this.config.baseDir);
47 | });
48 | cssModuleLoader.include = [].concat(itemLoader.include || []).concat(include);
49 | itemLoader.exclude = [].concat(itemLoader.exclude || []).concat(include);
50 | } else if (this.utils.isBoolean(cssModule)) {
51 | itemLoader.enable = false;
52 | }
53 | } else {
54 | // not fix: https://github.com/webpack-contrib/mini-css-extract-plugin/issues/126
55 | // /\.module\.scss/ 模式
56 | const test = cssModuleLoader.test;
57 | const testStr = test instanceof RegExp ? test.toString() : test;
58 | // /\.scss/ to /\.module\.scss/
59 | const cssModuleTest = testStr.replace('/\\.', '\\.module\\.').replace(/\/$/, '');
60 | const cssModuleTestRegex = new RegExp(cssModuleTest);
61 | cssModuleLoader.test = cssModuleTestRegex;
62 | cssModuleLoader.include = [cssModuleTestRegex];
63 | itemLoader.exclude = [cssModuleTestRegex];
64 | }
65 | loaders[cssModuleName] = cssModuleLoader;
66 | }
67 | }
68 | });
69 | }
70 |
71 | prepareEntry(entries) {
72 | return super.prepareEntry(entries, { loader: 'react-entry-template-loader', match: '.jsx' });
73 | }
74 | };
75 | module.exports = WebpackReactBaseBuilder;
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/lib/client.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const EasyWebpack = require('easywebpack');
3 | const WebpackReactBaseBuilder = require('./base');
4 | const babelrc = require('../config/babel.web');
5 | // eslint-disable-next-line new-cap
6 | class WebpackClientBuilder extends WebpackReactBaseBuilder(EasyWebpack.WebpackClientBuilder) {
7 | constructor(config = {}) {
8 | super(config);
9 | if (this.dev) {
10 | this.setAlias('react-dom', '@hot-loader/react-dom', false);
11 | }
12 | this.setBabelrc(babelrc);
13 | this.normalizeExtract(config);
14 | }
15 |
16 | normalizeExtract(config) {
17 | // default ssr dev extract true
18 | if (this.egg && !config.target) {
19 | this.mergePlugin({ extract: { env: ['dev'] } });
20 | }
21 | }
22 |
23 | createHotEntry() {
24 | if (this.hot) {
25 | super.createHotEntry();
26 | Object.keys(this.webpackConfig.entry).forEach(name => {
27 | this.webpackConfig.entry[name] = ['react-hot-loader/patch'].concat(this.webpackConfig.entry[name]);
28 | });
29 | }
30 | }
31 | }
32 | module.exports = WebpackClientBuilder;
33 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/lib/server.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const EasyWebpack = require('easywebpack');
3 | const WebpackReactBaseBuilder = require('./base');
4 | const babelrc = require('../config/babel.node');
5 | // eslint-disable-next-line new-cap
6 | class WebpackServerBuilder extends WebpackReactBaseBuilder(EasyWebpack.WebpackServerBuilder) {
7 | constructor(config) {
8 | super(config);
9 | this.setBabelrc(babelrc);
10 | this.setStyleLoader('isomorphic-style-loader');
11 | }
12 | }
13 | module.exports = WebpackServerBuilder;
14 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "easywebpack-react",
3 | "version": "5.0.0",
4 | "description": "React client render and server side render build solution for Webpack",
5 | "keywords": [
6 | "webpack",
7 | "easywebpack",
8 | "react"
9 | ],
10 | "dependencies": {
11 | "@babel/preset-react": "^7.0.0",
12 | "@hot-loader/react-dom": "^16.8.6",
13 | "babel-plugin-import": "^1.12.0",
14 | "easywebpack": "^5.0.0",
15 | "mkdirp": "^1.0.0",
16 | "isomorphic-style-loader": "^5.0.0",
17 | "react-entry-template-loader": "^1.0.0",
18 | "react-hot-loader": "^4.3.5"
19 | },
20 | "devDependencies": {
21 | "chai": "^4.0.0",
22 | "codecov": "^3.0.0",
23 | "conventional-changelog-cli": "^2.0.0",
24 | "cross-env": "^7.0.2",
25 | "eslint-config-eslint": "^6.0.0",
26 | "eslint-plugin-react": "^7.3.0",
27 | "mocha": "^8.1.3",
28 | "nyc": "^15.1.0",
29 | "react": "^16.0.0",
30 | "react-dom": "^16.0.0"
31 | },
32 | "engines": {
33 | "node": ">=10.0.0"
34 | },
35 | "scripts": {
36 | "lint": "eslint .",
37 | "fix": "eslint --fix .",
38 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
39 | "test": "nyc --reporter=html --reporter=text mocha --timeout=1000000",
40 | "cov": "nyc report --reporter=lcov && codecov --token=71d430b6-cb87-49b2-a156-2c55cd181ba4",
41 | "ci": "npm run lint && npm run cov",
42 | "ii": "yarn --registry https://registry.npmmirror.com",
43 | "pub": "npm publish --access=public"
44 | },
45 | "files": [
46 | "index.js",
47 | "lib",
48 | "config",
49 | "tool"
50 | ],
51 | "ci": {
52 | "version": "10, 12, 14"
53 | },
54 | "nyc": {
55 | "exclude": [
56 | "**/*.spec.js",
57 | "index.js",
58 | "lib/base.js",
59 | "config/plugin/**.js",
60 | "test/*.test.js"
61 | ]
62 | },
63 | "repository": {
64 | "type": "git",
65 | "url": "git+https://github.com/easy-team/easywebpack-react.git"
66 | },
67 | "publishConfig": {
68 | "tag": "5x"
69 | },
70 | "bugs": {
71 | "url": "https://github.com/easy-team/easywebpack-react/issues"
72 | },
73 | "homepage": "https://github.com/easy-team/easywebpack-react#readme",
74 | "author": "hubcarl@126.com",
75 | "license": "MIT"
76 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/test/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | html template
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-react/test/server.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const expect = require('chai').expect;
3 | const easywebpack = require('easywebpack');
4 | const webpack = easywebpack.webpack;
5 | const merge = easywebpack.merge;
6 | const WebpackServerBuilder = require('../lib/server');
7 | const path = require('path').posix;
8 |
9 | // http://chaijs.com/api/bdd/
10 | function createBuilder(config) {
11 | const builder = new WebpackServerBuilder(merge({
12 | cost: true,
13 | buildPath: 'dist/client',
14 | publicPath: '/public',
15 | entry: {
16 | 'client.test': path.join(__dirname, 'test/client.test.js')
17 | }
18 | }, config));
19 | if (config && config.type) {
20 | builder.type = config.type;
21 | }
22 | return builder;
23 | }
24 |
25 | function getLoaderByName(name, rules) {
26 | const loaderName = `${name}-loader`;
27 | return rules.find(rule => {
28 | return rule.use.some(loader => {
29 | return loaderName === loader || (typeof loader === 'object' && loader.loader === loaderName);
30 | });
31 | });
32 | }
33 |
34 | function getPluginByLabel(label, plugins) {
35 | return plugins.find(plugin => {
36 | return plugin.__lable__ === label || plugin.__plugin__ === label;
37 | });
38 | }
39 |
40 | describe('server.test.js', () => {
41 | before(() => {
42 | });
43 |
44 | after(() => {
45 | });
46 |
47 | beforeEach(() => {
48 | });
49 |
50 | afterEach(() => {
51 | });
52 |
53 | describe('#webpack hook test', () => {
54 | it('should create test', () => {
55 | const builder = createBuilder({
56 | create() {
57 | this.addEntry('config', path.join(__dirname, '../config/config.js'));
58 | },
59 | onServer() {
60 | this.addEntry('plugin', path.join(__dirname, '../utils/plugin.js'));
61 | }
62 | });
63 | const webpackConfig = builder.create();
64 | expect(webpackConfig.entry).to.include.keys(['client.test', 'config', 'plugin']);
65 | });
66 | });
67 |
68 | describe('#webpack externals test', () => {
69 | it('should externals config test', () => {
70 | const builder = createBuilder({});
71 | const webpackConfig = builder.create();
72 | expect(webpackConfig.externals.length).to.equal(1);
73 | expect(typeof webpackConfig.externals[0] === 'function').to.be.true;
74 | });
75 |
76 | it('should externals not use default config test', () => {
77 | const builder = createBuilder({
78 | nodeExternals: {
79 | useDefault: false
80 | }
81 | });
82 | const webpackConfig = builder.create();
83 | expect(webpackConfig.externals.length).to.equal(1);
84 | expect(typeof webpackConfig.externals[0] === 'function').to.be.true;
85 | });
86 | });
87 | });
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/.eslintignore:
--------------------------------------------------------------------------------
1 | test/fixtures
2 | coverage
3 | public
4 | test/web
5 | node_modules
6 | .spec.js
7 | coverage
8 | config
9 | .nyc_output
10 | *.test.js
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "parserOptions": { "ecmaVersion": 8 },
4 | "rules": {
5 | "default-param-last": "off",
6 | "require-unicode-regexp": "off",
7 | "prefer-regex-literals": "off",
8 | "jsdoc/implements-on-classes": "off",
9 | "padding-line-between-statements": "off",
10 | "no-param-reassign": "off",
11 | "no-unused-vars": "off",
12 | "no-prototype-builtins": "off",
13 | "camelcase":"off"
14 | }
15 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=javascript
2 | *.css linguist-language=javascript
3 | *.html linguist-language=javascript
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | npm-debug.log
3 | node_modules/
4 | coverage/
5 | .idea/
6 | run/
7 | .DS_Store
8 | *.swp
9 | .vscode
10 | *.iml
11 | dist
12 | public/
13 | .nyc_output
14 | package-lock.json
15 | *.log
16 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '8'
5 | - '9'
6 | script:
7 | - npm test
8 | after_success:
9 | - npm run cov
10 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017 sky.
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.
22 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/config/babel.node.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = {
3 | "presets": [
4 | ["@babel/preset-env", {
5 | "modules": false,
6 | "targets": {
7 | "node": "current"
8 | }
9 | }]
10 | ]
11 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/config/babel.web.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = {
3 | "presets": [
4 | ["@babel/preset-env", {
5 | "modules": false,
6 | "targets": {
7 | "browsers": ["last 2 versions", "> 1%", "Android >= 4.0", "ios >= 9"]
8 | }
9 | }]
10 | ],
11 | "plugins": [
12 | ["@babel/plugin-proposal-decorators", { "legacy": true }],
13 | ["@babel/plugin-proposal-class-properties", { "loose": true }],
14 | "@babel/plugin-proposal-async-generator-functions",
15 | "@babel/plugin-proposal-object-rest-spread",
16 | "@babel/plugin-transform-object-assign",
17 | "@babel/plugin-syntax-dynamic-import",
18 | "@babel/plugin-transform-runtime"
19 | ],
20 | "comments": false
21 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/config/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | hotCss: true,
3 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/config/loader.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | exports.vue = {
3 | test: /\.vue$/,
4 | exclude: /node_modules/,
5 | use() {
6 | const loader = this.resolveModule('vue-loader');
7 | return [{ loader }];
8 | }
9 | };
10 |
11 | exports.vuehtml = {
12 | test: /\.html$/,
13 | use: ['vue-html-loader']
14 | };
15 |
16 | exports.ts = {
17 | enable: false,
18 | options: {
19 | appendTsSuffixTo: [/\.vue$/]
20 | }
21 | };
22 |
23 | exports.urlimage = {
24 | options: {
25 | esModule: false
26 | }
27 | };
28 |
29 | exports.urlmedia = {
30 | options: {
31 | esModule: false
32 | }
33 | };
34 |
35 | exports.urlfont = {
36 | options: {
37 | esModule: false
38 | }
39 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/config/plugin.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const VueSSRDynamicChunkPlugin = require('./plugin/vue-ssr-dynamic-chunk-webpack-plugin');
3 |
4 | exports.vuessrchunk = {
5 | type: ['server'],
6 | name: new VueSSRDynamicChunkPlugin(),
7 | args: {
8 | }
9 | };
10 |
11 | exports.extract = {
12 | env: ['dev', 'test', 'prod'],
13 | };
14 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/config/plugin/vue-ssr-dynamic-chunk-webpack-plugin/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const fs = require('fs');
4 | const mkdirp = require('mkdirp');
5 |
6 | class VueSSRDynamicChunkPlugin {
7 | constructor(opts) {
8 | this.opts = Object.assign({ }, { chunk: true }, opts);
9 | }
10 |
11 | apply(compiler) {
12 | compiler.hooks.emit.tap('VueSSRDynamicChunkPlugin', (compilation, callback) => {
13 | const buildPath = compilation.options.output.path;
14 | const chunkPath = path.join(buildPath, 'node_modules');
15 |
16 | if (!fs.existsSync(chunkPath)) {
17 | mkdirp.sync(chunkPath);
18 | }
19 |
20 | compilation.chunks.forEach(chunk => {
21 | if (!this.opts.chunk) {
22 | return;
23 | }
24 |
25 | const asyncChunks = chunk.getAllAsyncChunks();
26 |
27 | asyncChunks && asyncChunks.forEach(asyncChunk => {
28 | asyncChunk.files.forEach(filename => {
29 | const filepath = path.join(chunkPath, filename);
30 | const source = compilation.assets[filename].source();
31 | fs.writeFileSync(filepath, source, 'utf8');
32 | });
33 | })
34 | });
35 | callback && callback();
36 | });
37 | }
38 | }
39 |
40 | module.exports = VueSSRDynamicChunkPlugin;
41 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/doc/images/webpack-vue-compile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/framework/easywebpack-vue/doc/images/webpack-vue-compile.png
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/doc/images/webpack-vue-debug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/framework/easywebpack-vue/doc/images/webpack-vue-debug.png
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const EasyWebpack = require('easywebpack');
3 | exports.EasyWebpack = EasyWebpack;
4 | Object.assign(exports, EasyWebpack);
5 | exports.WebpackClientBuilder = require('./lib/client');
6 | exports.WebpackServerBuilder = require('./lib/server');
7 |
8 | exports.getWebpackConfig = (config, option) => {
9 | return EasyWebpack.WebpackBuilder.getWebpackConfig(config, [exports.WebpackClientBuilder, exports.WebpackServerBuilder], option);
10 | };
11 |
12 | exports.getWebWebpackConfig = (config = {}, option = {}) => {
13 | return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackClientBuilder], option);
14 | };
15 |
16 | exports.getNodeWebpackConfig = (config = {}, option = {}) => {
17 | return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackServerBuilder], option);
18 | };
19 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/lib/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const { isVue3 } = require('./utils');
4 |
5 | const WebpackBaseBuilder = WebpackBuilder => class extends WebpackBuilder {
6 | constructor(config) {
7 | super(config);
8 | this.mergeConfig(require('../config/config'));
9 | this.mergeLoader(require('../config/loader'));
10 | this.mergePlugin(require('../config/plugin'));
11 | this.setExtensions('.vue');
12 | this.setResolveLoader({ modules: [path.join(__dirname, '../node_modules')] });
13 | this.createVueLoaderPlugin();
14 | }
15 |
16 | prepareEntry(entries) {
17 | return super.prepareEntry(entries, { loader: 'vue-entry-loader', match: '.vue' });
18 | }
19 |
20 | createVueLoaderPlugin() {
21 | if (isVue3(this.baseDir)) {
22 | const pluginModule = this.requireModule('vue-loader', this.modules);
23 | if (pluginModule) {
24 | const { VueLoaderPlugin } = pluginModule;
25 | if (VueLoaderPlugin) {
26 | this.addPlugin({ vueloader: { name: VueLoaderPlugin } });
27 | } else {
28 | this.addPlugin({ vueloader: { name: pluginModule } });
29 | }
30 | }
31 | } else {
32 | const VueLoaderPlugin = this.requireModule('vue-loader/lib/plugin.js', this.modules);
33 | this.addPlugin({ vueloader: { name: VueLoaderPlugin } });
34 | }
35 | }
36 | };
37 | module.exports = WebpackBaseBuilder;
38 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/lib/client.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const EasyWebpack = require('easywebpack');
3 | const { isVue3 } = require('./utils');
4 | const WebpackBaseBuilder = require('./base');
5 | const babelrc = require('../config/babel.web');
6 | // eslint-disable-next-line new-cap
7 | class WebpackClientBuilder extends WebpackBaseBuilder(EasyWebpack.WebpackClientBuilder) {
8 | constructor(config) {
9 | super(config);
10 | this.setBabelrc(babelrc);
11 | if (isVue3(this.baseDir)) {
12 | this.setAlias('vue', 'vue/dist/vue.runtime.esm-bundler.js', false);
13 | } else {
14 | this.setAlias('vue', 'vue/dist/vue.common.js', false);
15 | }
16 | }
17 | }
18 | module.exports = WebpackClientBuilder;
19 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/lib/server.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const EasyWebpack = require('easywebpack');
3 | const WebpackBaseBuilder = require('./base');
4 | const babelrc = require('../config/babel.node');
5 | // eslint-disable-next-line new-cap
6 | class WebpackServerBuilder extends WebpackBaseBuilder(EasyWebpack.WebpackServerBuilder) {
7 | constructor(config) {
8 | super(config);
9 | this.setBabelrc(babelrc);
10 | this.setDefine({ 'process.env.VUE_ENV': '"server"' });
11 | this.setAlias('vue', 'vue/dist/vue.runtime.common.js', false);
12 | this.setStyleLoader('vue-style-loader');
13 | }
14 | }
15 | module.exports = WebpackServerBuilder;
16 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/lib/utils.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const fs = require('fs');
4 | const semver = require('semver');
5 |
6 | exports.getPkgVersion = (baseDir, pkgName) => {
7 | const cwd = baseDir || process.cwd();
8 | const projectPkgFilePath = path.join(cwd, 'node_modules', pkgName, 'package.json');
9 | if (fs.existsSync(projectPkgFilePath)) {
10 | return require(projectPkgFilePath).version;
11 | }
12 | try {
13 | const resolvePkgPath = require.resolve(pkgName);
14 | const pkgFilePath = path.join(resolvePkgPath, 'package.json');
15 | if (fs.existsSync(pkgFilePath)) {
16 | return require(pkgFilePath).version;
17 | }
18 | // eslint-disable-next-line no-empty
19 | } catch (e) {}
20 | return null;
21 | };
22 |
23 | exports.isVue3 = baseDir => {
24 | const version = exports.getPkgVersion(baseDir, 'vue');
25 | if (version) {
26 | return semver.gte(semver.coerce(version).version, '3.0.0');
27 | }
28 | return false;
29 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "easywebpack-vue",
3 | "version": "5.1.1",
4 | "description": "vue webpack building solution for easywebpack",
5 | "keywords": [
6 | "webpack",
7 | "easywebpack",
8 | "vue"
9 | ],
10 | "dependencies": {
11 | "easywebpack": "^5.1.0",
12 | "semver": "^7.3.5",
13 | "vue-entry-loader": "^1.1.2",
14 | "vue-html-loader": "^1.2.4",
15 | "vue-loader": "^15.7.0",
16 | "vue-template-compiler": "^2.6.10"
17 | },
18 | "devDependencies": {
19 | "axios": "^0.20.0",
20 | "babel-preset-env": "^1.7.0",
21 | "chai": "^4.2.0",
22 | "codecov": "^3.2.0",
23 | "cross-env": "^7.0.2",
24 | "eslint": "^7.30.0",
25 | "eslint-config-eslint": "^7.0.0",
26 | "eslint-plugin-node": "^11.1.0",
27 | "mocha": "^8.1.3",
28 | "nyc": "^15.1.0",
29 | "runscript": "^1.5.1",
30 | "vue": "^2.6.10",
31 | "vue-router": "^3.0.2",
32 | "vuex": "^3.1.0",
33 | "vuex-router-sync": "^5.0.0"
34 | },
35 | "engines": {
36 | "node": ">=8.0.0"
37 | },
38 | "scripts": {
39 | "lint": "eslint .",
40 | "fix": "eslint --fix .",
41 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
42 | "test": "nyc --reporter=html --reporter=text mocha --timeout=1000000",
43 | "cov": "nyc report --reporter=lcov && codecov --token=c193e626-f08f-41a7-b3e7-fdc39878892f",
44 | "ci": "npm run lint && npm run cov",
45 | "ii": "yarn --registry https://registry.npmmirror.com"
46 | },
47 | "files": [
48 | "index.js",
49 | "lib",
50 | "config",
51 | "tool"
52 | ],
53 | "nyc": {
54 | "exclude": [
55 | "**/*.spec.js",
56 | "index.js",
57 | "config/*.js",
58 | "config/plugin/**/*.js",
59 | "test/*.test.js"
60 | ]
61 | },
62 | "ci": {
63 | "version": "8, 10, 12, 14"
64 | },
65 | "repository": {
66 | "type": "git",
67 | "url": "git+https://github.com/easy-team/easywebpack-vue.git"
68 | },
69 | "publishConfig": {
70 | "tag": "5x"
71 | },
72 | "bugs": {
73 | "url": "https://github.com/easy-team/easywebpack-vue/issues"
74 | },
75 | "homepage": "https://github.com/easy-team/easywebpack-vue#readme",
76 | "author": "hubcarl@126.com",
77 | "license": "MIT"
78 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/test/fixture/vue2/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-test",
3 | "version": "1.0.0",
4 | "devDependencies": {
5 | "vue": "^2.6.10",
6 | "vue-loader": "^15.0.0"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/test/fixture/vue3/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue3-test",
3 | "version": "1.0.0",
4 | "devDependencies": {
5 | "vue": "^3.1.4",
6 | "vue-loader": "^16.0.0"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/test/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | html template
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack-vue/test/utils.test.js:
--------------------------------------------------------------------------------
1 |
2 | 'use strict';
3 | const expect = require('chai').expect;
4 | const semver = require('semver');
5 |
6 | describe('test/utils.test.js', () => {
7 | describe('#semver test', () => {
8 | it('should semver api work', () => {
9 | expect(semver.gte('3.0.0', semver.coerce('3'))).to.be.true;
10 | expect(semver.gte(semver.coerce('3.0.0-beta.1').version, '3.0.0')).to.be.true;
11 | });
12 | })
13 | });
--------------------------------------------------------------------------------
/packages/framework/easywebpack/.eslintignore:
--------------------------------------------------------------------------------
1 | test/fixtures
2 | coverage
3 | public
4 | test/web
5 | node_modules
6 | .spec.js
7 | coverage
8 | config
9 | .nyc_output
10 | *.test.js
11 | utils/hot.js
--------------------------------------------------------------------------------
/packages/framework/easywebpack/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "parserOptions": { "ecmaVersion": 8 },
4 | "rules": {
5 | "default-param-last": "off",
6 | "require-unicode-regexp": "off",
7 | "prefer-regex-literals": "off",
8 | "jsdoc/implements-on-classes": "off",
9 | "padding-line-between-statements": "off",
10 | "no-param-reassign": "off",
11 | "no-unused-vars": "off",
12 | "no-prototype-builtins": "off",
13 | "camelcase":"off"
14 | }
15 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=javascript
2 | *.css linguist-language=javascript
3 | *.html linguist-language=javascript
--------------------------------------------------------------------------------
/packages/framework/easywebpack/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | npm-debug.log
3 | node_modules/
4 | coverage/
5 | .idea/
6 | run/
7 | .DS_Store
8 | *.swp
9 | .vscode
10 | *.iml
11 | config/buildConfig.json
12 | temp
13 | .nyc_output
14 | coverage.lcov
15 | /package-lock.json
16 | dist
17 | app
18 | .vscode
19 | yarn.lock
20 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '8'
5 | - '10'
6 | script:
7 | - npm test
8 | after_success:
9 | - npm run cov
10 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 sky
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.
22 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/config/babel.node.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = {
3 | "presets": [
4 | ["@babel/preset-env", {
5 | "modules": false,
6 | "targets": {
7 | "node": "current"
8 | }
9 | }]
10 | ]
11 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack/config/babel.web.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = {
3 | "presets": [
4 | ["@babel/preset-env", {
5 | "modules": false,
6 | "targets": {
7 | "browsers": ["last 2 versions", "> 1%", "Android >= 4.0", "ios >= 9"]
8 | }
9 | }]
10 | ],
11 | "plugins": [
12 | ["@babel/plugin-proposal-decorators", { "legacy": true }],
13 | ["@babel/plugin-proposal-class-properties", { "loose": true }],
14 | "@babel/plugin-proposal-async-generator-functions",
15 | "@babel/plugin-proposal-object-rest-spread",
16 | "@babel/plugin-syntax-dynamic-import",
17 | "@babel/plugin-transform-runtime"
18 | ],
19 | "comments": false
20 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack/config/config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const baseDir = process.cwd();
3 |
4 | exports.base = {
5 | config: {
6 | baseDir,
7 | port:9000,
8 | buildPath: 'dist',
9 | publicPath: '/',
10 | hashLength: 8,
11 | alias: {},
12 | packs: {},
13 | cdn: {},
14 | install:{
15 | check: false
16 | },
17 | postcss: true,
18 | compile:{
19 | cache: true,
20 | thread: true
21 | }
22 | },
23 | loaders: {},
24 | plugins: {}
25 | };
26 |
27 | exports.dev = {
28 | config: {
29 | hash: false
30 | },
31 | plugins:[{
32 | hot: true,
33 | }]
34 | };
35 |
36 | exports.test = {
37 | config: {
38 | hash: true,
39 | },
40 | plugins:[{
41 | hot: false,
42 | }]
43 | };
44 |
45 | exports.prod = {
46 | config: {
47 | hash: true,
48 | },
49 | plugins:{
50 | hot: false,
51 | }
52 | };
53 |
54 | exports.dll = {
55 | loaders: {
56 | eslint: false,
57 | scss: false,
58 | sass: false,
59 | less: false,
60 | stylus: false
61 | },
62 | plugins: {
63 | extract: false,
64 | html: false,
65 | runtime: false,
66 | commonsChunk: false,
67 | imagemini: false,
68 | manifest: false,
69 | manifestDll: true,
70 | tsChecker: false
71 | }
72 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack/config/loader.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | exports.babel = {
4 | enable: true,
5 | test: /\.jsx?$/,
6 | exclude: /node_modules/,
7 | use() {
8 | const loaders = [];
9 | const { compile = {} } = this.config;
10 | if (compile.thread) {
11 | loaders.unshift(this.createThreadLoader(compile.thread));
12 | }
13 | loaders.push(this.createBabelLoader());
14 | return loaders;
15 | }
16 | };
17 |
18 | exports.eslint = {
19 | enable: false,
20 | test: /\.jsx?$/,
21 | use: ['eslint-loader'],
22 | exclude: /node_modules/,
23 | enforce: 'pre'
24 | };
25 |
26 | exports.ts = {
27 | enable: false,
28 | test: /\.tsx?$/,
29 | exclude: /node_modules/,
30 | use() {
31 | return this.createTsLoader();
32 | }
33 | };
34 |
35 | exports.tslint = {
36 | enable: false,
37 | test: /\.tsx?$/,
38 | exclude: /node_modules/,
39 | enforce: 'pre',
40 | use: ['tslint-loader'],
41 | };
42 |
43 | exports.css = {
44 | enable: true,
45 | test: /\.css/,
46 | use: ['css-loader'],
47 | postcss: true,
48 | framework: true
49 | };
50 |
51 | exports.scss = {
52 | enable: false,
53 | test: /\.scss/,
54 | use: ['css-loader', 'sass-loader'],
55 | postcss: true,
56 | framework: true
57 | };
58 |
59 | exports.sass = {
60 | enable: false,
61 | test: /\.sass/,
62 | use: ['css-loader', {
63 | loader: 'sass-loader',
64 | options: {
65 | indentedSyntax: true
66 | }
67 | }],
68 | postcss: true,
69 | framework: true
70 | };
71 |
72 | exports.less = {
73 | enable: false,
74 | test: /\.less/,
75 | use: ['css-loader', 'less-loader'],
76 | postcss: true,
77 | framework: true
78 | };
79 |
80 | exports.stylus = {
81 | enable: false,
82 | test: /\.(stylus|styl)/,
83 | use: ['css-loader', 'stylus-loader'],
84 | postcss: true,
85 | framework: true
86 | };
87 |
88 | exports.urlimage = {
89 | enable: true,
90 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
91 | use: [
92 | {
93 | loader: 'url-loader',
94 | options: {
95 | limit: 1024
96 | },
97 | fn(){
98 | return {
99 | options: {
100 | name: this.webpackInfo.imageName
101 | }
102 | }
103 | }
104 | }
105 | ]
106 | };
107 |
108 | exports.urlmedia = {
109 | enable: true,
110 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
111 | use: [
112 | {
113 | loader: 'url-loader',
114 | options: {
115 | limit: 1024
116 | },
117 | fn(){
118 | return {
119 | options: {
120 | name: this.webpackInfo.mediaName
121 | }
122 | }
123 | }
124 | }
125 | ]
126 | }
127 |
128 | exports.urlfont = {
129 | enable: true,
130 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
131 | use: [
132 | {
133 | loader: 'url-loader',
134 | options: {
135 | limit: 1024
136 | },
137 | fn(){
138 | return {
139 | options: {
140 | name: this.webpackInfo.frontName
141 | }
142 | }
143 | }
144 | }
145 | ]
146 | };
147 |
148 | exports.nunjucks = {
149 | enable: false,
150 | type: 'client',
151 | test: /\.html$/,
152 | use: ['html-loader', {
153 | loader: 'nunjucks-html-loader',
154 | options: {
155 | searchPaths: ['src/widget','src/component']
156 | }
157 | }]
158 | };
159 |
160 | exports.ejs = {
161 | enable: false,
162 | type: 'client',
163 | test: /\.ejs/,
164 | use: ['ejs-loader']
165 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack/config/postcss.config.js:
--------------------------------------------------------------------------------
1 |
2 | 'use strict';
3 |
4 | module.exports = {
5 | plugins: [
6 | require('autoprefixer')({ overrideBrowserslist: ['iOS >= 8', 'Android >= 4.0'] })
7 | ]
8 | };
9 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/docs/easywebpack.md:
--------------------------------------------------------------------------------
1 |
2 | ## 非egg应用和插件, 单元测试和覆盖率
3 |
4 | https://istanbul.js.org/docs/tutorials/mocha/
5 |
6 | ## Webpack3
7 |
8 | - http://www.cnblogs.com/wmhuang/p/7065396.html
9 | - https://github.com/shaketbaby/directory-named-webpack-plugin
--------------------------------------------------------------------------------
/packages/framework/easywebpack/docs/images/easy-build-size.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/framework/easywebpack/docs/images/easy-build-size.png
--------------------------------------------------------------------------------
/packages/framework/easywebpack/docs/images/easy-egg-react.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/framework/easywebpack/docs/images/easy-egg-react.png
--------------------------------------------------------------------------------
/packages/framework/easywebpack/docs/images/easy-egg-vue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/framework/easywebpack/docs/images/easy-egg-vue.png
--------------------------------------------------------------------------------
/packages/framework/easywebpack/docs/images/easy-init.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/framework/easywebpack/docs/images/easy-init.png
--------------------------------------------------------------------------------
/packages/framework/easywebpack/docs/images/easywebpack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/framework/easywebpack/docs/images/easywebpack.png
--------------------------------------------------------------------------------
/packages/framework/easywebpack/docs/images/easywebpack.solution.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/easy-team/easywebpack/95f6b9d54dadd4dbf91bae84feef5d3fb542c3cf/packages/framework/easywebpack/docs/images/easywebpack.solution.png
--------------------------------------------------------------------------------
/packages/framework/easywebpack/docs/issue_template.md:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const WebpackTool = require('webpack-tool');
4 | exports.WebpackTool = WebpackTool;
5 | exports.webpack = WebpackTool.webpack;
6 | exports.merge = WebpackTool.merge;
7 | exports.Utils = require('./utils/utils');
8 | exports.WebpackBuilder = require('./lib/builder');
9 | exports.WebpackBaseBuilder = require('./lib/target/base');
10 | exports.WebpackClientBuilder = require('./lib/target/client');
11 | exports.WebpackServerBuilder = require('./lib/target/server');
12 | exports.WebpackDllBuilder = require('./lib/target/dll');
13 |
14 |
15 | exports.getConfig = (config = {}, option = {}) => {
16 | return exports.WebpackBuilder.getConfig(config, option);
17 | };
18 |
19 | exports.getWebpackConfig = (config = {}, option = {}) => {
20 | if (config.framework === 'dll' || option.onlyDll) {
21 | return exports.getDllWebpackConfig(config, option);
22 | }
23 | if (config.framework === 'js' || config.framework === 'web' || config.target === 'web' || option.onlyWeb) {
24 | return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackClientBuilder]);
25 | }
26 | if (config.framework === 'node' || config.target === 'node' || option.onlyNode) {
27 | return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackServerBuilder]);
28 | }
29 | return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackClientBuilder, exports.WebpackServerBuilder], option);
30 | };
31 |
32 | exports.getWebWebpackConfig = (config = {}, option = {}) => {
33 | return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackClientBuilder], option);
34 | };
35 |
36 | exports.getNodeWebpackConfig = (config = {}, option = {}) => {
37 | return exports.WebpackBuilder.getWebpackConfig(config, [exports.WebpackServerBuilder], option);
38 | };
39 |
40 | exports.getDllWebpackConfig = (config = {}, option = {}) => {
41 | if (option.singleConfig) {
42 | return new exports.WebpackDllBuilder(config).create();
43 | }
44 | return exports.WebpackBuilder.getDllWebpackConfig(config);
45 | };
46 |
47 | exports.build = async (webpackConfig, config, callback) => {
48 | return new WebpackTool(config).build(webpackConfig, config, callback);
49 | };
50 |
51 | exports.server = async (webpackConfig, config, callback) => {
52 | return new WebpackTool(config).server(webpackConfig, config, callback);
53 | };
54 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/lib/core/constant.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = {
3 | STYLE_LOADER: 'style-loader',
4 | CSS_LOADER: 'css-loader'
5 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack/lib/core/native.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const baseDir = process.cwd();
4 | const webpackConfig = {
5 | context: baseDir,
6 | entry: {},
7 | output: {},
8 | resolve: {
9 | extensions: ['.js']
10 | },
11 | externals: [],
12 | resolveLoader: {
13 | modules: [
14 | path.join(baseDir, 'node_modules')
15 | ]
16 | },
17 | stats: {
18 | colors: true,
19 | children: false,
20 | modules: false,
21 | chunks: false,
22 | chunkModules: false,
23 | entrypoints: false
24 | }
25 | };
26 |
27 | // yarn workspace / lerna
28 | if (process.env.INIT_CWD) {
29 | const initCwdModulePath = path.join(process.env.INIT_CWD, 'node_modules');
30 | if (!webpackConfig.resolveLoader.modules.some(m => m === initCwdModulePath)) {
31 | webpackConfig.resolveLoader.modules.push(initCwdModulePath);
32 | }
33 | }
34 |
35 | // current pkg module
36 | const currentModulePath = path.join(__dirname, '../../node_modules');
37 | if (!webpackConfig.resolveLoader.modules.some(m => m === currentModulePath)) {
38 | webpackConfig.resolveLoader.modules.push(currentModulePath);
39 | }
40 |
41 | module.exports = webpackConfig;
--------------------------------------------------------------------------------
/packages/framework/easywebpack/lib/core/output.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = {
3 |
4 | createFileName(config) {
5 | if ((config.hash && this.utils.isTrue(config.fileHash)) || config.fileHash) {
6 | this.setOutputFileName(this.utils.assetsPath(this.prefix, `js/[name].[chunkhash:${config.hashLength}].js`));
7 | this.setOutputFileChunkName(this.utils.assetsPath(this.prefix, `js/chunk/[name].[chunkhash:${config.hashLength}].js`));
8 | } else {
9 | this.setOutputFileName(this.utils.assetsPath(this.prefix, 'js/[name].js'));
10 | this.setOutputFileChunkName(this.utils.assetsPath(this.prefix, 'js/chunk/[name].js'));
11 | }
12 | },
13 |
14 | createImageName(config) {
15 | if ((config.hash && this.utils.isTrue(config.imageHash)) || config.imageHash) {
16 | this.webpackInfo.imageName = this.utils.assetsPath(this.prefix, `img/[name].[hash:${config.hashLength}].[ext]`);
17 | } else {
18 | this.webpackInfo.imageName = this.utils.assetsPath(this.prefix, 'img/[name].[ext]');
19 | }
20 | },
21 |
22 | createCssName(config) {
23 | if ((config.hash && this.utils.isTrue(config.cssHash)) || config.cssHash) {
24 | this.webpackInfo.cssName = this.utils.assetsPath(this.prefix, `css/[name].[contenthash:${config.hashLength}].css`);
25 | this.webpackInfo.cssChunkName = this.utils.assetsPath(this.prefix, `css/[id].[contenthash:${config.hashLength}].css`);
26 | } else {
27 | this.webpackInfo.cssName = this.utils.assetsPath(this.prefix, 'css/[name].css');
28 | this.webpackInfo.cssChunkName = this.utils.assetsPath(this.prefix, 'css/[id].css');
29 | }
30 | },
31 |
32 | createMediaName(config) {
33 | if ((config.hash && this.utils.isTrue(config.mediaHash)) || config.mediaHash) {
34 | this.webpackInfo.mediaName = this.utils.assetsPath(this.prefix, `media/[name].[hash:${config.hashLength}].[ext]`);
35 | } else {
36 | this.webpackInfo.mediaName = this.utils.assetsPath(this.prefix, 'media/[name].[ext]');
37 | }
38 | },
39 |
40 | createFrontName(config) {
41 | if ((config.hash && this.utils.isTrue(config.fontHash)) || config.fontHash) {
42 | this.webpackInfo.frontName = this.utils.assetsPath(this.prefix, `font/[name].[hash:${config.hashLength}].[ext]`);
43 | } else {
44 | this.webpackInfo.frontName = this.utils.assetsPath(this.prefix, 'font/[name].[ext]');
45 | }
46 | },
47 |
48 | createFileOption(config) {
49 | this.createFileName(config);
50 | this.createImageName(config);
51 | this.createCssName(config);
52 | this.createMediaName(config);
53 | this.createFrontName(config);
54 | }
55 |
56 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack/lib/target/dll.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const WebpackBaseBuilder = require('./base');
3 | const { dll } = require('../../config/config');
4 | const babelrc = require('../../config/babel.web');
5 | class WebpackDllBuilder extends WebpackBaseBuilder {
6 | constructor(config) {
7 | super(config);
8 | this.type = WebpackDllBuilder.TYPE;
9 | this.setBabelrc(babelrc);
10 | this.setTarget(WebpackDllBuilder.TARGET);
11 | this.mergeConfig(dll);
12 | this.setBuildPath(this.utils.getDllCompileFileDir(this.env), true);
13 | this.setLibrary('[name]');
14 | this.setStartCreateQueue(this.setBabelENV);
15 | this.setCreateQueue(this.createDllPlugin);
16 | }
17 |
18 | get dll() {
19 | return true;
20 | }
21 |
22 | createEntry(config) {
23 | const dllArray = WebpackDllBuilder.getDllConfig(config.dll);
24 | dllArray.forEach(item => {
25 | this.addEntry(item.name, item.lib);
26 | });
27 | }
28 |
29 | createOptimization() {
30 | return this.webpackOptimize.getDLLOptimization();
31 | }
32 | }
33 | WebpackDllBuilder.TYPE = 'client';
34 | WebpackDllBuilder.TARGET = 'web';
35 | module.exports = WebpackDllBuilder;
36 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/lib/target/server.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const fs = require('fs');
4 | const WebpackBaseBuilder = require('./base');
5 | const nodeExternals = require('webpack-node-externals');
6 | const babelrc = require('../../config/babel.web');
7 | class WebpackServerBuilder extends WebpackBaseBuilder {
8 | constructor(config) {
9 | super(config);
10 | this.ssr = true;
11 | this.type = WebpackServerBuilder.TYPE;
12 | this.setBabelrc(babelrc);
13 | this.setTarget(WebpackServerBuilder.TARGET);
14 | this.setNode({ __filename: false, __dirname: false });
15 | this.setLibraryTarget('commonjs');
16 | const notUseDefault = this.config.nodeExternals && this.config.nodeExternals.useDefault === false;
17 | /* istanbul ignore next */
18 | const defaultNodeExternals = notUseDefault ? { importType: 'commonjs' } : {
19 | importType: 'commonjs',
20 | allowlist: [moduleName => {
21 | const moduleDir = path.join(this.baseDir, 'node_modules', moduleName);
22 | const pkgFile = path.join(moduleDir, 'package.json');
23 | let moduleFile = 'index.js';
24 | /* istanbul ignore next */
25 | if (fs.existsSync(pkgFile)) {
26 | /* istanbul ignore next */
27 | moduleFile = require(pkgFile).main || moduleFile;
28 | }
29 | /* istanbul ignore next */
30 | const moduleEntry = path.join(this.baseDir, 'node_modules', moduleName, moduleFile);
31 | return !fs.existsSync(moduleEntry);
32 | }]
33 | };
34 | this.setExternals([nodeExternals(this.merge(defaultNodeExternals, this.config.nodeExternals))]);
35 | this.createFileName();
36 | this.setStartCreateQueue(this.setBabelENV);
37 | }
38 |
39 | get buildPath() {
40 | if (this.egg) {
41 | return this.utils.normalizeBuildPath('app/view', this.baseDir);
42 | }
43 | return super.buildPath;
44 | }
45 |
46 | createFileName() {
47 | this.setOutputFileName('[name].js');
48 | }
49 |
50 | createOptimization() {
51 | return this.webpackOptimize.getNodeOptimization();
52 | }
53 | }
54 | WebpackServerBuilder.TYPE = 'server';
55 | WebpackServerBuilder.TARGET = 'node';
56 | module.exports = WebpackServerBuilder;
57 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/lib/zero.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const fs = require('fs');
4 | const WebpackTool = require('webpack-tool');
5 | const merge = WebpackTool.merge;
6 | exports.initDLLDefault = function(config) {
7 | };
8 |
9 | exports.initDefault = function(config) {
10 | if (!config.target && !config.type) {
11 | config.target = 'web';
12 | }
13 | if (!config.entry) {
14 | config.entry = {
15 | index: 'src/app.js'
16 | };
17 | }
18 | if (config.template === undefined && ['vue', 'react', 'angular', 'html'].indexOf(config.framework) > -1) {
19 | const defaultTemplate = 'src/view/index.html';
20 | if (fs.existsSync(path.join(config.baseDir, defaultTemplate))) {
21 | config.template = defaultTemplate;
22 | }
23 | }
24 | return config;
25 | };
26 |
27 | exports.initEggDefault = function(config) {
28 | // 如果没有配置,Egg 应用构建路径默认为 public 和 /public/
29 | if (!config.buildPath) {
30 | config.buildPath = 'public';
31 | }
32 | if (!config.publicPath) {
33 | config.publicPath = '/public/';
34 | }
35 | // 设置默认 entry
36 | if (!config.entry) {
37 | if (config.framework === 'vue') {
38 | config.entry = 'app/web/page/**!(component|components|view|views)/*.vue';
39 | } else if (config.framework === 'react') {
40 | config.entry = 'app/web/page/**!(component|components|view|views)/*.jsx';
41 | }
42 | }
43 | // 设置默认 alias
44 | config.alias = merge({
45 | asset: 'app/web/asset',
46 | component: 'app/web/component',
47 | framework: 'app/web/framework'
48 | }, config.alias);
49 | return config;
50 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack/test/dll.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const fs = require('fs');
3 | const expect = require('chai').expect;
4 | const helper = require('./helper');
5 | const utils = require('../utils/utils');
6 | const WebpackDllBuilder = require('../lib/target/dll');
7 | const WebpackClientBuilder = require('../lib/target/client');
8 | const path = require('path').posix;
9 | const baseDir = path.join(__dirname, '..');
10 |
11 | class DllBuilder extends WebpackDllBuilder {
12 | constructor(config) {
13 | super(config);
14 | this.mergeConfig({
15 | buildPath: 'dist/vue',
16 | publicPath: 'public/dist'
17 | });
18 | }
19 | }
20 |
21 | describe('dll.test.js', () => {
22 | before(() => {
23 | });
24 |
25 | after(() => {
26 | });
27 |
28 | beforeEach(() => {
29 | });
30 |
31 | afterEach(() => {
32 | });
33 |
34 | describe('#webpack dll test', () => {
35 | it('should dll plugin config test', () => {
36 | const builder = new DllBuilder({
37 | baseDir,
38 | dll: ['mocha']
39 | });
40 | const webpackConfig = builder.create();
41 | const plugins = webpackConfig.plugins;
42 | expect(webpackConfig.entry).to.to.have.property('vendor');
43 | expect(!!helper.getPluginByLabel('DllPlugin', plugins)).to.be.true;
44 | });
45 |
46 | it('should dll refrence plugin test', () => {
47 | const filename = WebpackClientBuilder.getDllFilePath('vendor');
48 | if (!fs.existsSync(filename)) {
49 | utils.writeFile(filename, {
50 | name: 'vendor',
51 | content: {
52 | './node_modules/_vuex@3.0.1@vuex/dist/vuex.esm.js': {
53 | id: "./node_modules/_vuex@3.0.1@vuex/dist/vuex.esm.js",
54 | buildMeta: {}
55 | }
56 | }
57 | });
58 | }
59 | const builder = new WebpackClientBuilder({
60 | env: 'dev',
61 | entry: {
62 | include: __dirname
63 | },
64 | template: 'test/layout.html',
65 | dll: ['mocha']
66 | });
67 | const webpackConfig = builder.createWebpackConfig();
68 | const dllReferencePlugin = helper.getPluginByLabel('DllReferencePlugin', webpackConfig.plugins);
69 | expect(!!dllReferencePlugin).to.be.true;
70 | fs.unlinkSync(filename);
71 | });
72 | });
73 | });
74 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/test/helper.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const WebpackTool = require('webpack-tool');
4 | const merge = WebpackTool.merge;
5 | const WebpackBaseBuilder = require('../lib/target/base');
6 | const WebpackClientBuilder = require('../lib/target/client');
7 | const WebpackServerBuilder = require('../lib/target/server');
8 | const path = require('path').posix;
9 | // http://chaijs.com/api/bdd/
10 |
11 | exports.createBuilder = config => {
12 | const builder = new WebpackBaseBuilder(config);
13 | builder.setBuildPath(path.join(__dirname, '../dist/loader'));
14 | builder.setPublicPath('/public');
15 | builder.setEntry({
16 | include: path.join(__dirname, '../test')
17 | });
18 | return builder;
19 | };
20 |
21 | exports.createClientBuilder = config => {
22 | const builder = new WebpackClientBuilder(merge({
23 | entry: {
24 | include: path.join(__dirname)
25 | }
26 | }, config));
27 | if (config && config.type) {
28 | builder.type = config.type;
29 | }
30 | builder.setBuildPath(path.join(__dirname, 'dist/client'));
31 | builder.setPublicPath('/public');
32 | return builder;
33 | };
34 |
35 | exports.createServerBuilder = config => {
36 | const builder = new WebpackServerBuilder(merge({
37 | entry: {
38 | include: path.join(__dirname)
39 | }
40 | }, config));
41 | if (config && config.type) {
42 | builder.type = config.type;
43 | }
44 | builder.setBuildPath(path.join(__dirname, 'dist/server'));
45 | builder.setPublicPath('/public');
46 | return builder;
47 | };
48 |
49 |
50 | exports.getLoaderByName = (name, rules, test) => {
51 | const loaderName = `${name}-loader`;
52 | return rules.find(rule => {
53 | return rule.use.some(loader => {
54 | const hasLoader = loaderName === loader || (typeof loader === 'object' && loader.loader === loaderName);
55 | if (test && rule.test && typeof loader === 'object') {
56 | return rule.test.toString().indexOf(test) > -1 && hasLoader;
57 | }
58 | return hasLoader;
59 | });
60 | });
61 | };
62 |
63 | exports.getPluginByLabel = (label, plugins) => {
64 | return plugins.find(plugin => {
65 | return plugin.__lable__ === label || plugin.__plugin__ === label;
66 | });
67 | };
--------------------------------------------------------------------------------
/packages/framework/easywebpack/test/html.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const expect = require('chai').expect;
3 | const WebpackClientBuilder = require('../lib/target/client');
4 | const path = require('path').posix;
5 | const helper = require('./helper');
6 |
7 | // http://chaijs.com/api/bdd/
8 | function createBuilder(config) {
9 | const builder = new WebpackClientBuilder(config);
10 | if (config && config.type) {
11 | builder.type = config.type;
12 | }
13 | builder.setBuildPath(path.join(__dirname, 'dist/client'));
14 | builder.setPublicPath('/public');
15 | return builder;
16 | }
17 |
18 | function getAllPluginByLabel(label, plugins) {
19 | return plugins.filter(plugin => {
20 | return plugin.__lable__ === label || plugin.__plugin__ === label;
21 | });
22 | }
23 |
24 | describe('test/html.test.js', () => {
25 | before(() => {
26 | });
27 |
28 | after(() => {
29 | });
30 |
31 | beforeEach(() => {
32 | });
33 |
34 | afterEach(() => {
35 | });
36 |
37 | describe('#webpack html test', () => {
38 | it('should config html template', () => {
39 | const template = path.normalize(path.join(__dirname, 'layout.html'));
40 | const builder = createBuilder({
41 | entry:{
42 | client: './test/client.test.js'
43 | },
44 | template
45 | });
46 | const webpackConfig = builder.create();
47 | const htmlPlugins = helper.getPluginByLabel('html-webpack-plugin', webpackConfig.plugins);
48 | expect(webpackConfig.entry).to.include.keys(['client']);
49 | expect(htmlPlugins.userOptions.template).to.equal(template);
50 | });
51 |
52 | it('should entry string and html template test', () => {
53 | const template = path.normalize(path.join(__dirname, 'layout.html'));
54 | const builder = createBuilder({
55 | entry:'./test/client.test.js',
56 | template
57 | });
58 | const webpackConfig = builder.create();
59 | const htmlPlugins = helper.getPluginByLabel('html-webpack-plugin', webpackConfig.plugins);
60 | expect(webpackConfig.entry).to.include.keys(['client.test']);
61 | expect(htmlPlugins.userOptions.template).to.equal(template);
62 | });
63 |
64 | it('should entry dir html template test', () => {
65 | const template = path.normalize(path.join(__dirname, 'layout.html'));
66 | const builder = createBuilder({
67 | entry:'./test/*.js',
68 | template
69 | });
70 | const webpackConfig = builder.create();
71 | const htmlPlugins = helper.getPluginByLabel('html-webpack-plugin', webpackConfig.plugins);
72 | expect(webpackConfig.entry).to.include.keys(['base.test', 'client.test']);
73 | expect(Object.keys(webpackConfig.entry).length).to.equal(getAllPluginByLabel('html-webpack-plugin',webpackConfig.plugins).length);
74 | expect(htmlPlugins.userOptions.template).to.equal(template);
75 | });
76 | });
77 | });
--------------------------------------------------------------------------------
/packages/framework/easywebpack/test/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | html template
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/test/manifest.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const expect = require('chai').expect;
3 | const helper = require('./helper');
4 | const WebpackClientBuilder = require('../lib/target/client')
5 | const WebpackServerBuilder = require('../lib/target/server');
6 | const path = require('path').posix;
7 | const baseDir = path.join(__dirname, '..');
8 |
9 | class ClientBuilder extends WebpackClientBuilder {
10 | constructor(config) {
11 | super(config);
12 | this.mergePlugin({
13 | manifest: false
14 | }
15 | );
16 | }
17 | }
18 |
19 | describe('manifest.test.js', () => {
20 | before(() => {
21 | });
22 |
23 | after(() => {
24 | });
25 |
26 | beforeEach(() => {
27 | });
28 |
29 | afterEach(() => {
30 | });
31 |
32 | describe('#webpack manifest test', () => {
33 | it('should not use manifest config test', () => {
34 | const builder = new ClientBuilder({
35 | baseDir,
36 | entry: {
37 | include: __dirname,
38 | template: 'test/layout.html'
39 | }
40 | });
41 | const webpackConfig = builder.create();
42 | const plugins = webpackConfig.plugins;
43 | expect(!!helper.getPluginByLabel('manifest', plugins)).to.be.false;
44 | });
45 | });
46 |
47 | describe('#webpack manifest test', () => {
48 | it('should use manifest config test', () => {
49 | const builder = new ClientBuilder({
50 | baseDir,
51 | entry: {
52 | include: __dirname,
53 | template: 'test/layout.html'
54 | },
55 | plugins: {
56 | manifest: true
57 | }
58 | });
59 | const webpackConfig = builder.create();
60 | const plugins = webpackConfig.plugins;
61 | expect(!!helper.getPluginByLabel('manifest', plugins)).to.be.true;
62 | });
63 | });
64 |
65 | describe('#webpack manifest test', () => {
66 | it('should use manifest config test', () => {
67 | const builder = new ClientBuilder({
68 | baseDir,
69 | entry: {
70 | include: __dirname,
71 | template: 'test/layout.html'
72 | },
73 | plugins: {
74 | manifest: true,
75 | }
76 | });
77 | const webpackConfig = builder.create();
78 | const plugins = webpackConfig.plugins;
79 | expect(!!helper.getPluginByLabel('manifest', plugins)).to.be.true;
80 | });
81 | });
82 | describe('#webpack server manifest test', () => {
83 | it('should use manifest config test', () => {
84 | const builder = new WebpackServerBuilder({
85 | baseDir,
86 | entry: {
87 | include: __dirname
88 | }
89 | });
90 | const webpackConfig = builder.create();
91 | const plugins = webpackConfig.plugins;
92 | expect(!!helper.getPluginByLabel('manifest', plugins)).to.be.false;
93 | });
94 | });
95 | });
96 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/test/optimize.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const expect = require('chai').expect;
3 | const helper = require('./helper');
4 | // http://chaijs.com/api/bdd/
5 |
6 | describe('test/optimize.test.js', () => {
7 | before(() => {
8 | });
9 |
10 | after(() => {
11 | });
12 |
13 | beforeEach(() => {
14 | });
15 |
16 | afterEach(() => {
17 | });
18 |
19 | describe('#webpack optimize uglifyJs test', () => {
20 |
21 | it('should webpack optimize minimizer env dev test', () => {
22 | const builder = helper.createClientBuilder({});
23 | const webpackConfig = builder.create();
24 | expect(webpackConfig.optimization.minimizer).to.be.undefined;
25 | });
26 |
27 | it('should webpack optimize minimizer env dev test', () => {
28 | const builder = helper.createClientBuilder({
29 | plugins: {
30 | uglifyJs: {
31 | uglifyOptions: {
32 | warnings: false
33 | }
34 | }
35 | }
36 | });
37 | const webpackConfig = builder.create();
38 | expect(webpackConfig.optimization.minimizer).to.be.undefined;
39 | });
40 |
41 | it('should webpack optimize minimizer env prod test', () => {
42 | const builder = helper.createClientBuilder({
43 | env: 'prod',
44 | plugins: {
45 | uglifyJs: {
46 | uglifyOptions: {
47 | warnings: false
48 | }
49 | }
50 | }
51 | });
52 | const webpackConfig = builder.create();
53 | expect(webpackConfig.optimization.minimizer[0].constructor.name).to.equal('CssMinimizerPlugin');
54 | });
55 | });
56 | });
--------------------------------------------------------------------------------
/packages/framework/easywebpack/test/output.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const expect = require('chai').expect;
3 | const helper = require('./helper');
4 | const path = require('path');
5 | describe('output.test.js', () => {
6 | before(() => {
7 | });
8 |
9 | after(() => {
10 | });
11 |
12 | beforeEach(() => {
13 | });
14 |
15 | afterEach(() => {
16 | });
17 |
18 | describe('#webpack output test', () => {
19 | it('should webpack output.path and output.publicPath test', () => {
20 | const builder = helper.createBuilder({
21 | output: {
22 | path: __dirname,
23 | publicPath: '/test/'
24 | }
25 | });
26 | const webpackConfig = builder.create();
27 | expect(webpackConfig.output.path).to.be.equal(__dirname);
28 | expect(webpackConfig.output.publicPath).to.be.equal('/test/');
29 | });
30 | it('should webpack output.path-buildPath and output.publicPath-publicPath test', () => {
31 | const builder = helper.createClientBuilder({
32 | buildPath: 'old',
33 | publicPath: '/old/',
34 | output: {
35 | path: __dirname,
36 | publicPath: '/test/'
37 | }
38 | });
39 | const webpackConfig = builder.create();
40 | expect(webpackConfig.output.path).to.be.equal(__dirname);
41 | expect(webpackConfig.output.publicPath).to.be.equal('/test/');
42 | });
43 | it('should webpack output.path-buildPath and output.publicPath-publicPath egg test', () => {
44 | const builder = helper.createServerBuilder({
45 | egg: true,
46 | buildPath: 'old',
47 | publicPath: '/old/',
48 | output: {
49 | path: __dirname,
50 | publicPath: '/test/'
51 | }
52 | });
53 | const webpackConfig = builder.create();
54 | expect(webpackConfig.output.path).to.be.equal(path.join(process.cwd(), 'app/view'));
55 | expect(webpackConfig.output.publicPath).to.be.equal('/test/');
56 | });
57 | });
58 | });
59 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/test/rule.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const expect = require('chai').expect;
3 | const helper = require('./helper');
4 |
5 | describe('rules.test.js', () => {
6 | before(() => {
7 | });
8 |
9 | after(() => {
10 | });
11 |
12 | beforeEach(() => {
13 | });
14 |
15 | afterEach(() => {
16 | });
17 |
18 | describe('#webpack rule test', () => {
19 | it('should webpack rules enable test', () => {
20 | const builder = helper.createBuilder({
21 | module: {
22 | rules: [
23 | {
24 | eslint: true
25 | },
26 | {
27 | babel: false
28 | },
29 | {
30 | urlfont: false
31 | },
32 | {
33 | urlmedia: false
34 | },
35 | ]
36 | }
37 | });
38 | const webpackConfig = builder.create();
39 | const rules = webpackConfig.module.rules;
40 | expect(helper.getLoaderByName('eslint', rules).use[0].loader).to.equal('eslint-loader');
41 | expect(helper.getLoaderByName('babel', rules)).to.be.undefined;
42 | expect(helper.getLoaderByName(/\.(woff2?|eot|ttf|otf)(\?.*)?$/, rules)).to.be.undefined;
43 | });
44 |
45 | it('should webpack rules options test', () => {
46 | const config = {
47 | module: {
48 | rules: [
49 | {
50 | eslint: {
51 | fix: true
52 | }
53 | }
54 | ]
55 | }
56 | };
57 | const builder = helper.createBuilder(config);
58 | const webpackConfig = builder.create();
59 | const rules = webpackConfig.module.rules;
60 | const eslint = helper.getLoaderByName('eslint', rules);
61 | expect(eslint.use[0].options.fix).to.be.true;
62 | });
63 | });
64 | });
65 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/test/test.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const expect = require('chai').expect;
3 | const helper = require('./helper');
4 | const utils = require('../utils/utils');
5 | const WebpackBaseBuilder = require('../lib/target/base');
6 | const WebpackClientBuilder = require('../lib/target/client');
7 | const path = require('path').posix;
8 |
9 | // http://chaijs.com/api/bdd/
10 | function createBuilder(config) {
11 | const builder = new WebpackBaseBuilder(config);
12 | builder.setBuildPath(path.join(__dirname, '../dist/loader'));
13 | builder.setPublicPath('/public');
14 | builder.setEntry({
15 | include: path.join(__dirname, '../test')
16 | });
17 | return builder;
18 | }
19 |
20 | function createClientBuilder(config) {
21 | const builder = new WebpackClientBuilder(config);
22 | builder.setBuildPath(path.join(__dirname, '../dist/loader'));
23 | builder.setPublicPath('/public');
24 | builder.setEntry({
25 | include: path.join(__dirname, '../test')
26 | });
27 | return builder;
28 | }
29 |
30 | function getLoadersByName(name, rules) {
31 | const loaderName = `${name}-loader`;
32 | return rules.filter(rule => {
33 | return rule.use.some(loader => {
34 | return loaderName === loader || (typeof loader === 'object' && loader.loader === loaderName);
35 | });
36 | });
37 | }
38 | function getLoaderByTest(test, rules) {
39 | return rules.find(rule => {
40 | return rule.test.toString() === test.toString();
41 | });
42 | }
43 |
44 | describe('loader.test.js', () => {
45 | before(() => {
46 | });
47 |
48 | after(() => {
49 | });
50 |
51 | beforeEach(() => {
52 | });
53 |
54 | afterEach(() => {
55 | });
56 |
57 |
58 | describe('#webpack loader options cache test', () => {
59 | it('should loader options', () => {
60 | const builder = createBuilder({
61 | module: {
62 | rules: [
63 | { babel:
64 | {
65 | include: __dirname,
66 | exclude: [__dirname]
67 | }
68 | },
69 | {
70 | options: { // 扩展配置
71 | babel: {
72 | options: {
73 | flag: 1
74 | }
75 | }
76 | }
77 | }
78 | ]
79 | }
80 | });
81 | const webpackConfig = builder.create();
82 | const babelLoader = helper.getLoaderByName('babel', webpackConfig.module.rules);
83 | expect(babelLoader.include).to.equal(__dirname);
84 | expect(babelLoader.exclude[0]).to.equal(__dirname);
85 | expect(babelLoader.use[1].options.flag).to.equal(1);
86 | });
87 | });
88 | });
89 |
--------------------------------------------------------------------------------
/packages/framework/easywebpack/test/utils.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const expect = require('chai').expect;
3 | const utils = require('../utils/utils');
4 |
5 | describe('test/utils.test.js', () => {
6 | describe('#utils test', () => {
7 | it('should ip test', () => {
8 | const ip = utils.getIp();
9 | expect(ip.split('.').length).to.be.equal(4);
10 | });
11 | it('should getLoaderLabel test work for loader name', () => {
12 | const label = utils.getLoaderLabel({ loader: 'test-loader' });
13 | expect(label).to.be.equal('test');
14 | });
15 | it('should getLoaderLabel test work for loade path', () => {
16 | const label = utils.getLoaderLabel({ loader: '/easy/test/test-loader' });
17 | expect(label).to.be.equal('test');
18 | });
19 | });
20 | });
--------------------------------------------------------------------------------
/packages/framework/easywebpack/utils/hot.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | if (typeof window === 'object') {
3 | var hotClient = require('webpack-hot-middleware/client?noInfo=false&reload=true&quiet=false&autoConnect=false');
4 | var currentHash;
5 | hotClient.setOptionsAndConnect({
6 | path: EASY_ENV_HOST_URL + '/__webpack_hmr'
7 | });
8 | hotClient.subscribeAll(function(event) {
9 | if (event.action === 'built' && currentHash) {
10 | var request = new XMLHttpRequest();
11 | var requestPath = EASY_ENV_PUBLIC_PATH + currentHash + '.hot-update.json';
12 | request.open("GET", requestPath, true);
13 | request.timeout = 5000;
14 | request.send(null);
15 | request.onreadystatechange = function() {
16 | if (request.readyState === 4) {
17 | if (request.status === 200) {
18 | try {
19 | var update = JSON.parse(request.responseText);
20 | var c = update.c;
21 | if (!c || JSON.stringify(c) === '{}' || /:true/.test(JSON.stringify(c))) {
22 | var links = document.getElementsByTagName('link');
23 | for (var i = 0; i < links.length; i++) {
24 | var href = links[i].href;
25 | if (href && /\.css$/.test(href)) {
26 | links[i].href = href;
27 | console.log('[HMR] ' + href + ' updated.');
28 | }
29 | }
30 | }
31 | } catch (e) {
32 | console.log('Get hot-update.json content error', e);
33 | }
34 | }
35 | }
36 | };
37 | }
38 | currentHash = event.hash || currentHash;
39 | });
40 | }
--------------------------------------------------------------------------------
/packages/framework/easywebpack/utils/logger.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const chalk = require('chalk');
3 | const TAG = 'easywebpack';
4 | class Logger {
5 | constructor(option = {}, builder) {
6 | this.option = option;
7 | this.builder = builder;
8 | this.name = this.builder.constructor.name;
9 | }
10 |
11 | setOption(option) {
12 | this.option = option;
13 | }
14 |
15 | info(info, tag = TAG) {
16 | console.log(chalk.blue(`[${this.name}] ${tag}:`), typeof info === 'object' ? info : chalk.green(info));
17 | }
18 |
19 | warn(info, tag = TAG) {
20 | console.log(chalk.blue(`[${tag}]:`), typeof info === 'object' ? info : chalk.yellow(info));
21 | }
22 |
23 | deprecated(info, tag = TAG) {
24 | console.log(chalk.blue(`[${tag}]:`), typeof info === 'object' ? info : chalk.yellow(info));
25 | }
26 |
27 | print(tag, info) {
28 | if (this.option.enable === undefined || this.option.enable) {
29 | this.info(info, tag);
30 | }
31 | }
32 |
33 | cost() {
34 | if (this.builder.config.cost) {
35 | this.info(`------ init cost: ${this.builder.t2 - this.builder.t1}, init create cost: ${this.builder.t3 - this.builder.t2}, create cost: ${this.builder.t4 - this.builder.t3} -------, create total cost: ${this.builder.t4 - this.builder.t1} -------\r\n`, 'cost');
36 | }
37 | }
38 |
39 | debug(webpackConfig) {
40 | this.env();
41 | this.config();
42 | this.keyword();
43 | this.options();
44 | this.all(webpackConfig);
45 | }
46 |
47 | line(tag, info) {
48 | this.lineStart(tag);
49 | this.print(tag, info);
50 | this.lineEnd(tag);
51 | }
52 |
53 | lineStart(tag) {
54 | this.print(tag, '-------------------start-------------------------');
55 | }
56 |
57 | lineEnd(tag) {
58 | this.print(tag, '-------------------end-------------------------');
59 | }
60 |
61 | env() {
62 | if (this.option.env) {
63 | this.info(`------ NODE_ENV: ${process.env.NODE_ENV}, BUILD_ENV: ${process.env.BUILD_ENV}, UPLOAD_CDN: ${process.env.UPLOAD_CDN} -------`, 'env');
64 | }
65 | }
66 |
67 | all(info) {
68 | if (this.option.all) {
69 | this.lineStart('all');
70 | if (info) {
71 | this.print('all', info);
72 | } else {
73 | this.config();
74 | this.keyword();
75 | this.loader();
76 | this.plugin();
77 | }
78 | this.lineEnd('all');
79 | }
80 | }
81 |
82 | config() {
83 | if (this.option.config) {
84 | this.print('config', this.builder.config);
85 | }
86 | }
87 |
88 | keyword() {
89 | if (this.option.keyword) {
90 | this.print('env', this.builder.env);
91 | this.print('extractCss', this.builder.extractCss);
92 | this.print('buildPath', this.builder.buildPath);
93 | this.print('publicPath', this.builder.publicPath);
94 | this.print('filename', this.builder.filename);
95 | this.print('imageName', this.builder.imageName);
96 | this.print('cssName', this.builder.cssName);
97 | }
98 | }
99 |
100 | options(options) {
101 | if (this.option.options) {
102 | this.print('options', options || this.builder.options);
103 | }
104 | }
105 |
106 | loader(loaders) {
107 | if (this.option.loader) {
108 | this.line('loaders', loaders);
109 | }
110 | }
111 |
112 | plugin(plugins) {
113 | if (this.option.plugin) {
114 | this.line('plugins', plugins);
115 | }
116 | }
117 | }
118 |
119 | module.exports = Logger;
120 |
--------------------------------------------------------------------------------
/packages/plugin/react-entry-loader/.eslintignore:
--------------------------------------------------------------------------------
1 | test/fixtures
2 | coverage
3 | public
4 | test/web
5 | node_modules
6 | .spec.js
7 | coverage
8 | config
9 | .nyc_output
10 | *.test.js
--------------------------------------------------------------------------------
/packages/plugin/react-entry-loader/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "parserOptions": { "ecmaVersion": 8 },
4 | "rules": {
5 | "default-param-last": "off",
6 | "require-unicode-regexp": "off",
7 | "prefer-regex-literals": "off",
8 | "jsdoc/implements-on-classes": "off",
9 | "padding-line-between-statements": "off",
10 | "no-param-reassign": "off",
11 | "no-unused-vars": "off",
12 | "no-prototype-builtins": "off",
13 | "camelcase":"off",
14 | "func-style": "off",
15 | "jsdoc/require-jsdoc": "off"
16 | }
17 | }
--------------------------------------------------------------------------------
/packages/plugin/react-entry-loader/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=javascript
2 | *.css linguist-language=javascript
3 | *.html linguist-language=javascript
--------------------------------------------------------------------------------
/packages/plugin/react-entry-loader/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | npm-debug.log
3 | node_modules/
4 | coverage/
5 | .idea/
6 | run/
7 | .DS_Store
8 | *.swp
9 | vscode
10 | *.iml
11 | package-lock.json
12 |
--------------------------------------------------------------------------------
/packages/plugin/react-entry-loader/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '6'
5 | - '8'
6 | - '9'
7 | script:
8 | - npm test
9 | after_success:
10 | - npm run ci
11 |
--------------------------------------------------------------------------------
/packages/plugin/react-entry-loader/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 | ## [1.0.3](https://github.com/hubcarl/react-entry-template-loader/compare/1.0.2...1.0.3) (2020-01-11)
3 |
4 |
5 | ### Bug Fixes
6 |
7 | * compitable asyncData mode ([7f21ec7](https://github.com/hubcarl/react-entry-template-loader/commit/7f21ec7))
8 |
9 |
10 |
11 | ## [1.0.2](https://github.com/hubcarl/react-entry-template-loader/compare/1.0.1...1.0.2) (2019-07-27)
12 |
13 |
14 | ### Bug Fixes
15 |
16 | * hydrate mode for client render and server render ([3b9b87d](https://github.com/hubcarl/react-entry-template-loader/commit/3b9b87d))
17 |
18 |
19 |
20 | ## 1.0.1 (2019-07-17)
21 |
22 |
23 | ### Bug Fixes
24 |
25 | * client render chrome console warning ([baf59e6](https://github.com/hubcarl/react-entry-template-loader/commit/baf59e6))
26 |
27 |
28 | ## 1.0.0 (2018-10-04)
29 |
30 | ### Features
31 |
32 | * init ([c1d28ca](https://github.com/hubcarl/react-entry-template-loader/commit/c1d28ca))
33 |
34 |
35 |
--------------------------------------------------------------------------------
/packages/plugin/react-entry-loader/README.md:
--------------------------------------------------------------------------------
1 | # react-entry-template-loader
2 |
3 | [![NPM version][npm-image]][npm-url]
4 | [![build status][travis-image]][travis-url]
5 | [![Test coverage][codecov-image]][codecov-url]
6 | [![David deps][david-image]][david-url]
7 | [![Known Vulnerabilities][snyk-image]][snyk-url]
8 | [![npm download][download-image]][download-url]
9 |
10 | [npm-image]: https://img.shields.io/npm/v/react-entry-template-loader.svg?style=flat-square
11 | [npm-url]: https://npmjs.org/package/react-entry-template-loader
12 | [travis-image]: https://img.shields.io/travis/hubcarl/react-entry-template-loader.svg?style=flat-square
13 | [travis-url]: https://travis-ci.org/hubcarl/react-entry-template-loader
14 | [codecov-image]: https://img.shields.io/codecov/c/github/hubcarl/react-entry-template-loader.svg?style=flat-square
15 | [codecov-url]: https://codecov.io/github/hubcarl/react-entry-template-loader?branch=master
16 | [david-image]: https://img.shields.io/david/hubcarl/react-entry-template-loader.svg?style=flat-square
17 | [david-url]: https://david-dm.org/hubcarl/react-entry-template-loader
18 | [snyk-image]: https://snyk.io/test/npm/react-entry-template-loader/badge.svg?style=flat-square
19 | [snyk-url]: https://snyk.io/test/npm/react-entry-template-loader
20 | [download-image]: https://img.shields.io/npm/dm/react-entry-template-loader.svg?style=flat-square
21 | [download-url]: https://npmjs.org/package/react-entry-template-loader
22 |
23 | React Entry Template Loader for easywebapck
24 |
25 | ## Featues
26 |
27 | ## License
28 |
29 | [MIT](LICENSE)
30 |
--------------------------------------------------------------------------------
/packages/plugin/react-entry-loader/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const loaderUtils = require('loader-utils');
4 | const node = require('./lib/node');
5 | const web = require('./lib/web');
6 | module.exports = function(source) {
7 | this.cacheable();
8 | const options = loaderUtils.getOptions(this) || {};
9 | const config = { codeSegment: '' };
10 | const loader = this.target === 'node' ? node : web;
11 | return loader(this, source, options, config);
12 | };
13 |
--------------------------------------------------------------------------------
/packages/plugin/react-entry-loader/lib/node.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = (context, source, options, config) => {
3 | context.cacheable();
4 | return `
5 | import React, { Component } from 'react';
6 | import App from '${context.resourcePath.replace(/\\/g, '\\\\')}';
7 | export default App.asyncData ? App : class Page extends Component {
8 | render() {
9 | return ;
10 | }
11 | }
12 | `;
13 | };
--------------------------------------------------------------------------------
/packages/plugin/react-entry-loader/lib/web.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = (context, source, options, config) => {
3 | context.cacheable();
4 | return `
5 | import React from 'react';
6 | import ReactDom from 'react-dom';
7 | import { AppContainer } from 'react-hot-loader';
8 | import Entry from '${context.resourcePath.replace(/\\/g, '\\\\')}';
9 | const state = window.__INITIAL_STATE__;
10 | const render = (App)=>{
11 | const root = document.getElementById('app');
12 | const renderMode = root.childNodes.length > 0 ? 'hydrate' : 'render';
13 | ReactDom[renderMode](EASY_ENV_IS_DEV ? : , root);
14 | };
15 |
16 | if (EASY_ENV_IS_DEV && module.hot) {
17 | module.hot.accept('${context.resourcePath.replace(/\\/g, '\\\\')}', () => { render(Entry) });
18 | }
19 | render(Entry);
20 | `;
21 | };
--------------------------------------------------------------------------------
/packages/plugin/react-entry-loader/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-entry-template-loader",
3 | "version": "1.0.3",
4 | "description": "react entry template loader for easywebpack",
5 | "keywords": [
6 | "webpack",
7 | "react",
8 | "entry",
9 | "loader",
10 | "easywebpack"
11 | ],
12 | "dependencies": {
13 | "loader-utils": "^1.1.0"
14 | },
15 | "devDependencies": {
16 | "chai": "^4.1.1",
17 | "codecov": "^3.0.0",
18 | "conventional-changelog-cli": "^1.3.5",
19 | "eslint": "^4.5.0",
20 | "eslint-config-eslint": "^4.0.0",
21 | "mocha": "^3.5.0",
22 | "nyc": "^11.1.0"
23 | },
24 | "engines": {
25 | "node": ">=6.0.0"
26 | },
27 | "scripts": {
28 | "lint": "eslint .",
29 | "fix": "eslint --fix .",
30 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
31 | "test": "nyc --reporter=html --reporter=text mocha --timeout=1000000",
32 | "cov": "nyc report --reporter=lcov && codecov --token=e971d1e7-39e2-44b1-b1ee-f4345b0adbee",
33 | "ci": "npm run lint && npm run cov",
34 | "ii": "npm install --registry https://registry.npmmirror.com"
35 | },
36 | "nyc": {
37 | "exclude": [
38 | "**/*.spec.js",
39 | "test/*.test.js"
40 | ]
41 | },
42 | "ci": {
43 | "version": "10, 12, 14"
44 | },
45 | "repository": {
46 | "type": "git",
47 | "url": "git+https://github.com/hubcarl/react-entry-template-loader.git"
48 | },
49 | "publishConfig": {
50 | "tag": "next"
51 | },
52 | "bugs": {
53 | "url": "https://github.com/hubcarl/react-entry-template-loader/issues"
54 | },
55 | "homepage": "https://github.com/hubcarl/react-entry-template-loader#readme",
56 | "author": "hubcarl@126.com",
57 | "license": "MIT"
58 | }
59 |
--------------------------------------------------------------------------------
/packages/plugin/react-entry-loader/test/lib.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const expect = require('chai').expect;
4 | // http://chaijs.com/api/bdd/
5 | describe('lib.test.js', () => {
6 | before(() => {});
7 |
8 | after(() => {});
9 |
10 | beforeEach(() => {});
11 |
12 | afterEach(() => {});
13 |
14 | describe('#expect lib test', () => {
15 | it('should unit api test', () => {
16 | expect(true).to.be.true;
17 | expect(false).to.be.false;
18 | expect(undefined).to.be.undefined;
19 | expect([1, 2, 3]).to.have.property(1);
20 | expect(['.js', '.jsx', '.vue']).to.include.members(['.js', '.jsx']);
21 | expect({ id: 1, name: 'sky' }).to.include.all.keys(['id', 'name']);
22 | });
23 | });
24 | });
25 |
--------------------------------------------------------------------------------
/packages/plugin/vue-entry-loader/.eslintignore:
--------------------------------------------------------------------------------
1 | test/fixtures
2 | coverage
3 | public
4 | test/web
5 | node_modules
6 | .spec.js
7 | coverage
8 | config
9 | .nyc_output
10 | *.test.js
--------------------------------------------------------------------------------
/packages/plugin/vue-entry-loader/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "parserOptions": { "ecmaVersion": 8 },
4 | "rules": {
5 | "default-param-last": "off",
6 | "require-unicode-regexp": "off",
7 | "prefer-regex-literals": "off",
8 | "jsdoc/implements-on-classes": "off",
9 | "padding-line-between-statements": "off",
10 | "no-param-reassign": "off",
11 | "no-unused-vars": "off",
12 | "no-prototype-builtins": "off",
13 | "camelcase":"off",
14 | "func-style": "off",
15 | "jsdoc/require-jsdoc": "off"
16 | }
17 | }
--------------------------------------------------------------------------------
/packages/plugin/vue-entry-loader/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=javascript
2 | *.css linguist-language=javascript
3 | *.html linguist-language=javascript
--------------------------------------------------------------------------------
/packages/plugin/vue-entry-loader/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | npm-debug.log
3 | node_modules/
4 | coverage/
5 | .idea/
6 | run/
7 | .DS_Store
8 | *.swp
9 | vscode
10 | *.iml
11 | package-lock.json
12 |
--------------------------------------------------------------------------------
/packages/plugin/vue-entry-loader/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - '6'
5 | - '8'
6 | - '9'
7 | script:
8 | - npm test
9 | after_success:
10 | - npm run ci
11 |
--------------------------------------------------------------------------------
/packages/plugin/vue-entry-loader/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 | ## [1.1.5](https://github.com/hubcarl/vue-entry-loader/compare/1.1.4...1.1.5) (2019-12-27)
3 |
4 |
5 | ### Bug Fixes
6 |
7 | * cannot show fullpath in build file ([0cf954e](https://github.com/hubcarl/vue-entry-loader/commit/0cf954e))
8 |
9 |
10 |
11 | ## [1.1.4](https://github.com/hubcarl/vue-entry-loader/compare/1.1.3...1.1.4) (2019-12-06)
12 |
13 |
14 | ### Bug Fixes
15 |
16 | * use templateFile relative path ([9659851](https://github.com/hubcarl/vue-entry-loader/commit/9659851))
17 |
18 |
19 |
20 | ## [1.1.3](https://github.com/hubcarl/vue-entry-loader/compare/1.1.2...1.1.3) (2019-07-27)
21 |
22 |
23 | ### Bug Fixes
24 |
25 | * vue hydrate for server sider render and client render ([d78b69b](https://github.com/hubcarl/vue-entry-loader/commit/d78b69b))
26 |
27 |
28 |
29 |
30 | ## [1.1.2](https://github.com/hubcarl/vue-entry-loader/compare/1.1.1...1.1.2) (2019-01-11)
31 |
32 |
33 | ### Bug Fixes
34 |
35 | * https://github.com/easy-team/vue-entry-loader/issues/1 ([8fcc399](https://github.com/hubcarl/vue-entry-loader/commit/8fcc399))
36 |
37 |
38 |
39 |
40 | ## [1.1.1](https://github.com/hubcarl/vue-entry-loader/compare/1.1.0...1.1.1) (2019-01-11)
41 |
42 |
43 | ### Bug Fixes
44 |
45 | * optimize css and js build order ([7f846b4](https://github.com/hubcarl/vue-entry-loader/commit/7f846b4))
46 |
47 |
48 |
49 |
50 | # [1.1.0](https://github.com/hubcarl/vue-entry-loader/compare/1.0.1...1.1.0) (2018-10-16)
51 |
52 |
53 | ### Features
54 |
55 | * support dynamic create store and router ([230c7ea](https://github.com/hubcarl/vue-entry-loader/commit/230c7ea))
56 |
57 |
58 |
59 |
60 | ## [1.0.1](https://github.com/hubcarl/vue-entry-loader/compare/1.0.0...1.0.1) (2018-10-10)
61 |
62 |
63 | ### Bug Fixes
64 |
65 | * windows path error ([1ca1beb](https://github.com/hubcarl/vue-entry-loader/commit/1ca1beb))
66 |
67 |
68 |
69 |
70 | # [1.0.0](https://github.com/hubcarl/vue-entry-loader/compare/0.1.0...1.0.0) (2018-09-17)
71 |
72 |
73 | ### Features
74 |
75 | * 1.0.0 ([2b8ee89](https://github.com/hubcarl/vue-entry-loader/commit/2b8ee89))
76 |
77 |
78 |
79 |
80 | # 0.1.0 (2018-09-17)
81 |
82 |
83 | ### Features
84 |
85 | * init ([9333f0e](https://github.com/hubcarl/vue-entry-loader/commit/9333f0e))
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/packages/plugin/vue-entry-loader/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const loaderUtils = require('loader-utils');
4 | const node = require('./lib/node');
5 | const web = require('./lib/web');
6 | module.exports = function(source) {
7 | this.cacheable();
8 | const options = loaderUtils.getOptions(this) || {};
9 | const config = { codeSegment: '' };
10 | if (options.templateFile) {
11 | // fix windows path error
12 | const templateFilePath = path.resolve(this.rootContext, options.templateFile);
13 | const nomarlizeTemplateFilePath = templateFilePath.replace(/\\/g, '\\\\');
14 | config.codeSegment = `import codeSegment from '${nomarlizeTemplateFilePath}'
15 | codeSegment(Vue);`;
16 | }
17 | const loader = this.target === 'node' ? node : web;
18 | const content = loader(this, source, options, config);
19 | return content;
20 | };
21 |
--------------------------------------------------------------------------------
/packages/plugin/vue-entry-loader/lib/node.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = (context, source, options, config) => {
3 | return `
4 | import Vue from 'vue';
5 | ${config.codeSegment}
6 | import vm from '${context.resourcePath.replace(/\\/g, '\\\\')}';
7 | export default function(context) {
8 | const store = typeof vm.store === 'function' ? vm.store(context.state) : vm.store;
9 | const router = typeof vm.router === 'function' ? vm.router() : vm.router;
10 | if (store && router) {
11 | const sync = require('vuex-router-sync').sync;
12 | sync(store, router);
13 | router.push(context.state.url);
14 | return new Promise((resolve, reject) => {
15 | router.onReady(() => {
16 | const matchedComponents = router.getMatchedComponents();
17 | if (!matchedComponents) {
18 | return reject({ code: '404' });
19 | }
20 | return Promise.all(
21 | matchedComponents.map(component => {
22 | if (component.methods && component.methods.fetchApi) {
23 | return component.methods.fetchApi(store);
24 | }
25 | return null;
26 | })
27 | ).then(() => {
28 | context.state = { ...store.state, ...context.state };
29 | const hook = vm.hook || Vue.hook || {};
30 | const render = hook.render || vm.hookRender || Vue.hookRender;
31 | if (render) {
32 | render(context, vm);
33 | }
34 | const instanceOptions = {
35 | ...vm,
36 | store,
37 | router,
38 | };
39 | return resolve(new Vue(instanceOptions));
40 | });
41 | });
42 | });
43 | }
44 | const VueApp = Vue.extend(vm);
45 | const hook = vm.hook || Vue.hook || {};
46 | const render = hook.render || vm.hookRender || Vue.hookRender;
47 | if (render) {
48 | render(context, vm);
49 | }
50 | const instanceOptions = {
51 | ...vm,
52 | data: context.state
53 | };
54 | return new VueApp(instanceOptions);
55 | };
56 | `;
57 | };
--------------------------------------------------------------------------------
/packages/plugin/vue-entry-loader/lib/web.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | module.exports = (context, source, options, config) => {
3 | return `
4 | import Vue from 'vue';
5 | ${config.codeSegment}
6 | import vm from '${context.resourcePath.replace(/\\/g, '\\\\')}';
7 | const initState = window.__INITIAL_STATE__ || {};
8 | const context = { state: initState };
9 | const hook = vm.hook || Vue.hook || {};
10 | const render = hook.render || vm.hookRender || Vue.hookRender;
11 | if (render) {
12 | render(context, vm);
13 | }
14 | const store = typeof vm.store === 'function' ? vm.store(initState) : vm.store;
15 | const router = typeof vm.router === 'function' ? vm.router() : vm.router;
16 | const data = typeof vm.data === 'function' ? vm.data() : {};
17 | const options = store && router ? {
18 | ...vm,
19 | store,
20 | router
21 | } : {
22 | ...vm,
23 | ...{
24 | data() {
25 | return { ...initState, ...data};
26 | }
27 | }
28 | };
29 | const app = new Vue({
30 | store,
31 | router,
32 | render: h => h(vm)
33 | });
34 | const root = document.getElementById('app');
35 | const hydrate = root.childNodes.length > 0;
36 | app.$mount(root, hydrate);
37 | `;
38 | };
--------------------------------------------------------------------------------
/packages/plugin/vue-entry-loader/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-entry-loader",
3 | "version": "1.1.5",
4 | "description": "webpack vue entry initialization template code",
5 | "keywords": [
6 | "easyjs",
7 | "easywebpack",
8 | "webpack",
9 | "vue",
10 | "entry",
11 | "loader",
12 | "vue-entry-template"
13 | ],
14 | "dependencies": {
15 | "loader-utils": "^1.1.0"
16 | },
17 | "devDependencies": {
18 | "chai": "^4.1.1",
19 | "codecov": "^3.0.0",
20 | "conventional-changelog-cli": "^1.3.5",
21 | "eslint": "^4.5.0",
22 | "eslint-config-eslint": "^4.0.0",
23 | "mocha": "^3.5.0",
24 | "nyc": "^11.1.0"
25 | },
26 | "engines": {
27 | "node": ">=6.0.0"
28 | },
29 | "scripts": {
30 | "lint": "eslint .",
31 | "fix": "eslint --fix .",
32 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
33 | "test": "nyc --reporter=html --reporter=text mocha --timeout=1000000",
34 | "cov": "nyc report --reporter=lcov && codecov --token=e971d1e7-39e2-44b1-b1ee-f4345b0adbee",
35 | "ci": "npm run lint && npm run cov",
36 | "ii": "npm install --registry https://registry.npmmirror.com"
37 | },
38 | "nyc": {
39 | "exclude": [
40 | "**/*.spec.js",
41 | "test/*.test.js"
42 | ]
43 | },
44 | "ci": {
45 | "version": "10, 12, 14"
46 | },
47 | "repository": {
48 | "type": "git",
49 | "url": "git+https://github.com/hubcarl/vue-entry-loader.git"
50 | },
51 | "publishConfig": {
52 | "tag": "next"
53 | },
54 | "bugs": {
55 | "url": "https://github.com/hubcarl/vue-entry-loader/issues"
56 | },
57 | "homepage": "https://github.com/hubcarl/vue-entry-loader#readme",
58 | "author": "hubcarl@126.com",
59 | "license": "MIT"
60 | }
--------------------------------------------------------------------------------
/packages/plugin/vue-entry-loader/test/lib.test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | const path = require('path');
3 | const expect = require('chai').expect;
4 | // http://chaijs.com/api/bdd/
5 | describe('lib.test.js', () => {
6 | before(() => {
7 | });
8 |
9 | after(() => {
10 | });
11 |
12 | beforeEach(() => {
13 | });
14 |
15 | afterEach(() => {
16 | });
17 |
18 | describe('#expect lib test', () => {
19 | it('should unit api test', () => {
20 | expect(true).to.be.true;
21 | expect(false).to.be.false;
22 | expect(undefined).to.be.undefined;
23 | expect([1,2,3]).to.have.property(1);
24 | expect(['.js','.jsx','.vue']).to.include.members(['.js','.jsx']);
25 | expect({id: 1, name: 'sky'}).to.include.all.keys(['id', 'name']);
26 | });
27 | });
28 | });
--------------------------------------------------------------------------------