react-app-rewire-multiple-entry
Advanced tools
Comparing version 2.2.2 to 2.2.3
@@ -52,3 +52,3 @@ "use strict"; | ||
return { | ||
name: (0, _utils.formatName)(entry.entry), | ||
name: (0, _utils.formatName)(entry.entry, (entry?.omitHash)), | ||
entry: entryPath, | ||
@@ -55,0 +55,0 @@ template: entry.template, |
@@ -5,2 +5,3 @@ export interface EntryParam { | ||
outPath?: string; | ||
omitHash?: boolean; | ||
} | ||
@@ -7,0 +8,0 @@ export interface EntryWebpack { |
@@ -1,2 +0,2 @@ | ||
export declare const formatName: (name: string) => string; | ||
export declare const formatName: (name: string, omitHash?: boolean) => string; | ||
export declare const checkFileExist: (file: string) => void; |
@@ -18,2 +18,4 @@ "use strict"; | ||
var formatName = function formatName(name) { | ||
var omitHash = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
if (!name) { | ||
@@ -23,3 +25,9 @@ name = ''; | ||
return name.split('/').reverse()[0].match(/^[^.]*/)[0] + '.' + H.update(name).digest().toString(16); | ||
var filenamePrefix = name.split('/').reverse()[0].match(/^[^.]*/)[0]; | ||
if (omitHash) { | ||
return filenamePrefix; | ||
} | ||
return filenamePrefix + '.' + H.update(name).digest().toString(16); | ||
}; | ||
@@ -26,0 +34,0 @@ |
{ | ||
"name": "react-app-rewire-multiple-entry", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "Multiple Entry Support for Create-React-App", | ||
@@ -58,2 +58,3 @@ "main": "lib/index.js", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.4.0", | ||
"@babel/plugin-syntax-optional-chaining": "^7.8.3", | ||
"@babel/plugin-transform-modules-commonjs": "^7.7.4", | ||
@@ -69,3 +70,3 @@ "@babel/preset-env": "^7.4.1", | ||
"prettier": "^1.16.4", | ||
"typescript": "^3.3.3" | ||
"typescript": "^4.7.2" | ||
}, | ||
@@ -72,0 +73,0 @@ "dependencies": { |
@@ -44,3 +44,4 @@ [React App Rewire Multiple Entry] lets you configure multiple entries in [Create React App] | ||
template: 'public/landing.html', | ||
outPath: '/landing.html' | ||
outPath: '/landing.html', | ||
omitHash: false, | ||
} | ||
@@ -66,3 +67,4 @@ ]); | ||
template: 'public/landing.html', | ||
outPath: '/landing.html' | ||
outPath: '/landing.html', | ||
omitHash: false, | ||
} | ||
@@ -141,2 +143,3 @@ ]); | ||
- `outPath`: [Optional] The file wirte the HTML to. You can specify a subdirectory. **If empty, it will be calculated by `path.relative(process.cwd(), template)`** | ||
- `omitHash` [Optional] Omit the hash for each entry name. Default value: `false`, generate hash for entry. | ||
@@ -143,0 +146,0 @@ ### Method |
@@ -42,3 +42,3 @@ import path from 'path'; | ||
return { | ||
name: formatName(entry.entry), | ||
name: formatName(entry.entry, entry?.omitHash), | ||
entry: entryPath, | ||
@@ -45,0 +45,0 @@ template: entry.template, |
@@ -5,3 +5,4 @@ | ||
template?: string, | ||
outPath?: string | ||
outPath?: string, | ||
omitHash?: boolean | ||
} | ||
@@ -8,0 +9,0 @@ |
@@ -6,11 +6,18 @@ import fs from 'fs'; | ||
export const formatName = function (name: string) { | ||
export const formatName = function (name: string, omitHash: boolean = false) { | ||
if (!name) { | ||
name = ''; | ||
} | ||
return ( | ||
name | ||
const filenamePrefix = name | ||
.split('/') | ||
.reverse()[0] | ||
.match(/^[^.]*/)[0] + | ||
.match(/^[^.]*/)[0]; | ||
if (omitHash) { | ||
return filenamePrefix; | ||
} | ||
return ( | ||
filenamePrefix + | ||
'.' + | ||
@@ -17,0 +24,0 @@ H.update(name) |
Sorry, the diff of this file is not supported yet
24609
429
156
17