Giter Site home page Giter Site logo

ymfe / ykit Goto Github PK

View Code? Open in Web Editor NEW
392.0 27.0 56.0 4.79 MB

基于 Webpack 的灵活快速的打包工具,帮助稳定高效构建现代 JavaScript 应用。

Home Page: https://ykit.ymfe.org/

License: Apache License 2.0

JavaScript 99.71% HTML 0.22% CSS 0.07%
ymfe javascript module-loader build-tool compiler webpack ykit

ykit's Introduction

YKit CircleCI

ENGLISH DOC

YKit 是一个基于 Webpack 的打包工具,它利用插件机制封装了各种 JavaScript 应用的配置,选择和安装合适的插件即可开始构建你的应用。

特性

  • 通过 init 命令快速初始化各种环境
  • 封装各类配置,减少搭建环境工作量
  • 包含 hot-reload 的本地 server

安装

  • latest 稳定版: [sudo] npm install ykit -g
  • 或者选择基于 [email protected] 的最新版本:[sudo] npm install ykit@next -g

快速开始

  1. 创建目录 mkdir ykit-app && cd ykit-app
  2. 初始化工程 ykit init
  3. 启动服务 ykit s -p 3000
  4. 用浏览器访问 http://127.0.0.1:3000/index.html

初始化结束后,项目中会生成一个名为 ykit.js 的配置文件:

module.exports = {
    plugins: [],
    config: {
        export: ['./scripts/index.js', './styles/index.css'],
        modifyWebpackConfig: function (baseConfig) {
            // 更改 Webpack 配置
            return baseConfig;
        }
    },
    hooks: {},
    commands: []
};

配置文件选项

  • plugins - 插件是对一类配置和功能的封装,通过安装插件可以快速搭建开发环境
  • config.exports - 资源入口
  • config.modifyWebpackConfig - 用来更改 Webpack 现有配置的函数
  • hooks - 打包过程钩子
  • commands - 自定义命令

范例

通过插件快速搭建不同类型的应用,可参考以下示例。

文档

访问 ykit.ymfe.org 来获取更多 YKit 的文档。

ykit's People

Contributors

edwonlim avatar ellery0924 avatar jasonfang93 avatar malcolmyu avatar wy-ei avatar yuhaoju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ykit's Issues

First blood

It's such a shock that I will open the first issue of ykit!In a word, it spending too much time to compile after ykit generated too many webpack dev middleware. It's a disaster to multi-page application.

Reproduce the problem

  1. create a ykit demo with 4 exports;
  2. start a ykit server;
  3. visit these exports in chrome;
  4. edit a public module which is imported by all of these exports;
  5. visit one of them again.

Expected output

The export can be visited in 5 seconds.

What I see instead

It responds after all of these exports compiled successfully, and the duration is tens of seconds in general.

Version

0.4.1

alias 支持软连接吗

ykit.js 中 config.resolve.alias 里面的 key 是 新name,value是path,这个path是不支持绝对路径的,但是 可以是 软连接吗,我测试软连接是不可以的, 是因为软连接 也解析成绝对路径吗,所以软连接也不支持吗

前端页面二次开发疑问

请问一下,static文件夹下的index引用的是prd下的文件,我通过ykit pack -m打包了新文件,并且修改了assets.js 引用的文件均为新打包生成的文件
window.WEBPACK_ASSETS = {"index.js":{"js":"[email protected]","css":"[email protected]"},"lib":{"js":"[email protected]"},"lib2":{"js":"[email protected]"},"lib3":{"js":"[email protected]"},"manifest":{"js":"[email protected]"}}

但是启动yapi服务器后,进入首页,页面无法正常显示样式,请问这个过程需要怎么修改才能显示修改后的前端页面呢?

YKit 用户收集

这里统计一下正在使用 YKit 的用户,以便 YKit 团队能够更好更快速的获取大家的建议和需求,并及时响应。

大家可以在这里回复并告知一下你所在的公司

macbook pro node6.9.2报少browser.js

✖ [00:23:30] 1 error in compiling process.
[error] in ../.nvm/versions/node/v6.9.2/lib//ykit//process/browser.js
Module build failed: ReferenceError: Unknown plugin "transform-decorators-legacy" specified in "base" at 0, attempted to resolve relative to "/Users/xxx/.nvm/versions/node/v6.9.2/lib/node_modules/ykit/node_modules/process"
at Array.map (native)

关于YAPI启动开发环境和测试环境的区别疑问

npm run star 和npm run dev 的具体区别是什么,只是入口文件分别是index.html 和dev.html的区别么,他们在代码结构上有什么区别么?为什么我把client里的所有文件都删除了 ,npm run star和npm run dev 还是可以正常运行,并且代码入口都是app.js

ykit init 指令报错

用的是最新版2.01
执行 ykit init 的时候报错

错误信息:
PS D:\project\ykit-startkit> ykit init
C:\Users\zihaocao\AppData\Roaming\nvm\v8.3.0\node_modules\ykit\lib\commands\init.js:22
Manager.reloadRC();
^

TypeError: Manager.reloadRC is not a function
at Object.exports.run (C:\Users\zihaocao\AppData\Roaming\nvm\v8.3.0\node_modules\yk
it\lib\commands\init.js:22:10)
at Object.run (C:\Users\zihaocao\AppData\Roaming\nvm\v8.3.0\node_modules\ykit\lib\c
li.js:91:24)
at Object. (C:\Users\zihaocao\AppData\Roaming\nvm\v8.3.0\node_modules\yk
it\bin\ykit:8:5)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Function.Module.runMain (module.js:609:10)
at startup (bootstrap_node.js:158:16)
PS D:\project\ykit-startkit>

path.js:39 throw new ERR_INVALID_ARG_TYPE('path', 'string', path);

使用ykit 打包是报错了

  • ykit pack -m
    path.js:39
    throw new ERR_INVALID_ARG_TYPE('path', 'string', path);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at assertPath (path.js:39:11)
at Object.join (path.js:1155:7)
at Object. (/usr/local/lib/node_modules/ykit/lib/global.js:26:28)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
Build step 'Execute shell' marked build as failure
Finished: FAILURE

请教关于设置代理解决跨域的问题

系统环境为MAC
直接用 ykit s -p 4000 启动服务器,然后前端请求接口也是127.0.0.1:4000;
请教下怎么设置代理呢,我试过在ykit.config的 server 中加上 proxy: { '/api': { target: 'http://127.0.0.1:3000', changeOrigin: true } }
但是没有生效

Hi,希望加一个功能,能够复制测试集合

1,如题所示,公司业务需要,是否能加这个功能?
2,另外我问一下,因为业务需要,我想改动一点源码。现在开发和生产的环境下,调用的js都是静态的资源,我问一下在开发模式下,怎么用“client”下的资源,而不是打包后的呢?谢谢!

Yii 已存在的接口:/company/index.php[GET],添加不了

{{host}}/company/index.php?r=crm/member/index/check-member&verify_action=renew
{{host}}/company/index.php?r=crm/member/index/select-member&verify_action=renew
我的两个方法都是用get 会报错已存在的接口:/company/index.php[GET]

ykit关于发布到production环境react报错的问题

使用ykit打包到production环境,前端页面报 React is running in production mode, but dead code elimination has not been applied. Read how to correctly configure React for production,但在ykit.config.js里面,发现production的配置没有问题,配置如下,麻烦问下如何解决,线上环境NODE_ENV为production
modifyWebpackConfig: function (baseConfig) {
var ENV_PARAMS = {};
switch (this.env) {
case 'local':
ENV_PARAMS = 'dev';
break;
case 'dev':
ENV_PARAMS = 'dev';
break;
case 'prd':
ENV_PARAMS = 'production';
break;
default:
}

prd 目录没有 index.html?

执行 ykit pack -m 命令后,prd 目录没有 index.html

尝试添加 html-webpack-plugin,结果错误:

Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'

如果要给每个文件加上 hash,该怎么做?

如何使用ykit打包到指定路径呢

试了下ykit pack不支持 -d 参数,默认打包是到项目文件夹下的dev或者prod 如果想打包到指定路径应该怎么操作? 我在config里面配置了output 但并不好用~~ ps: 打包的时候发现index.html没有一起被打包过去 不知道是不是因为没有使用HtmlWebpackPlugin

TypeError: this.applymiddleware is not a function

enviroment

[email protected]
[email protected]

issue:

when i execute command ykit server -m, i Fall into a problem.
then error is
/Users/lishuai/bee/test/ykit.js:8 this.applymiddleware((req, res, next) => { TypeError: this.applymiddleware is not a function at Object.modifyWebpackConfig (/Users/lishuai/bee/test/ykit.js:8:12) at Config.setCompiler (/Users/lishuai/.nvm/versions/node/v7.9.0/lib/node_modules/ykit/lib/models/Config.js:159:64) at Project.handleExportsConfig (/Users/lishuai/.nvm/versions/node/v7.9.0/lib/node_modules/ykit/lib/models/Project.js:363:29) at Project.readConfig (/Users/lishuai/.nvm/versions/node/v7.9.0/lib/node_modules/ykit/lib/models/Project.js:256:47) at new Project (/Users/lishuai/.nvm/versions/node/v7.9.0/lib/node_modules/ykit/lib/models/Project.js:76:14) at Object.exports.getProject (/Users/lishuai/.nvm/versions/node/v7.9.0/lib/node_modules/ykit/lib/modules/manager.js:93:29) at Object.run (/Users/lishuai/.nvm/versions/node/v7.9.0/lib/node_modules/ykit/lib/cli.js:67:31) at Object.<anonymous> (/Users/lishuai/.nvm/versions/node/v7.9.0/lib/node_modules/ykit/bin/ykit:8:5) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10)

my ykit.js is

var path = require('path');
module.exports = {
config: {
exports: ['./scripts/app.js'],
modifyWebpackConfig: function (baseConfig) {
// 示例:处理 .hello 类型文件,全部返回文字 "hello!"
this.applymiddleware((req, res, next) => {
if (path.extname(req.url) === '.hello') {
res.end('hello!'); // 直接返回结果
} else {
next(); // 不进行处理,转给后续中间件
}
})
return baseConfig;
}
}
};

please help me ~

在使用ykit server时报错

Module not found: Error: Cannot resolve module 'es3ify-loader' in /usr/local/opt/nvm/versions/node/v6.9.2/lib/node_modules/ykit/node_modules/html-entities

自己去包里安装下这个依赖后解决。 ykit版本是0.8.3-beta.0

好像发现一个地方写错了

ykit 版本 [email protected]

src/commands/server.js

middlewares = options.mw || options.middlewares,

options 下面 只有m 没有mw

然后

$ sudo ykit s --middlewares

会报错。 middlewares 不是true 吗 ? middlewares.split 是要干嘛

if (middlewares) {
        middlewares.split('|').forEach((proName) => {
            let pro = Manager.getProject(path.join(cwd, proName));
            if (pro.check() && Array.isArray(pro.middlewares)) {
                pro.middlewares.forEach((mw) => app.use(mw));
            }
        });
}

win7环境下 执行ykit pack 报错

win7环境下 执行ykit pack 失败(node npm ykit 已经是最新版本),提示 ykit.js 第一行的 module 未定义 , win10环境可以执行
wechatimg50

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.