UNPKG

silki

Version:

Cli tool for build react app, based on generator-react-multipage, create-react-app, roadhog. Support react multiple pages app develop.

32 lines (27 loc) 898 B
'use strict'; var glob = require('glob'); var isProduction = process.env.NODE_ENV === 'production'; // 获取所有入口文件 var getEntry = function getEntry(globPath, config) { var entries = {}; if (!config.noVendor && (isProduction || !config.dll)) { entries = { vendor: ['react', 'react-dom', 'whatwg-fetch'] // 类库 }; } glob.sync(globPath).forEach(function (entry) { // let pathname = entry.split('/').splice(-2).join('/').split('.')[0]; var reg = /\.(js|jsx)$/; var pathname = entry.split('/').splice(-2).join('/').replace(reg, ''); if (!config.multipage && globPath.indexOf('*') === -1) { pathname = 'index'; } if (isProduction) { entries[pathname] = [entry]; } else { entries[pathname] = [require.resolve('react-dev-utils/webpackHotDevClient'), entry]; } }); return entries; }; module.exports = getEntry;