多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] * * * * * # 1 配置目录(config\\) ~~~ inferno-master\config\ DOM.js ;jsdom配置 index.html ;测试结果显示页面 karma.conf.js ;karma测试配置 mocha.opts ;mocha测试配置 rollup.config.js ;rollup打包配置 webpack.dev.conf.js ;webpack测试打包配置 ~~~ # 2 配置功能 > 包含框架的测试,构建等配置文件。 # 3 框架模块组织 ~~~ config\rollup.config.js ...... ;框架模块组织(7个模块) ;Inferno,InfernoDOM,InfernoServer ;InfernoComponent,InfernoTestUtils ;InfernoCreateElement,InfernoRouter const bundles = [ { moduleGlobal: 'Inferno', moduleName: 'inferno', moduleEntry: 'packages/inferno/src/index.js' }, { moduleGlobal: 'InfernoDOM', moduleName: 'inferno-dom', moduleEntry: 'packages/inferno-dom/src/index.js' }, { moduleGlobal: 'InfernoServer', moduleName: 'inferno-server', moduleEntry: 'packages/inferno-server/src/index.js' }, { moduleGlobal: 'InfernoComponent', moduleName: 'inferno-component', moduleEntry: 'packages/inferno-component/src/index.js' }, { moduleGlobal: 'InfernoTestUtils', moduleName: 'inferno-test-utils', moduleEntry: 'packages/inferno-test-utils/src/index.js' }, { moduleGlobal: 'InfernoCreateElement', moduleName: 'inferno-create-element', moduleEntry: 'packages/inferno-create-element/src/index.js' }, { moduleGlobal: 'InfernoRouter', moduleName: 'inferno-router', moduleEntry: 'packages/inferno-router/src/index.js' } ]; ...... ;打包过程 ;根据上面框架模块配置 ;打包输出到packages/inferno/dis/moduleName/xx.js function createBundle({moduleGlobal, moduleName, moduleEntry}) { const copyright = '/*!\n' + ' * ' + moduleName + ' v' + pack.version + '\n' + ' * (c) ' + new Date().getFullYear() + ' ' + pack.author.name + '\n' + ' * Released under the ' + pack.license + ' License.\n' + ' */'; const entry = p.resolve(moduleEntry); const dest = p.resolve(`packages/inferno/dist/${ moduleName }.${ process.env.NODE_ENV === 'production' ? 'min.js' : 'js' }`); const bundleConfig = { dest, format: 'umd', moduleName: moduleGlobal, globals: { moduleGlobal: moduleGlobal }, banner: copyright, sourceMap: false }; return rollup({entry, plugins}).then(({write}) => write(bundleConfig)).catch(err => { console.log(err) }); } ...... ~~~