-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
171 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,7 @@ h3 { | |
.content { | ||
flex: 1; | ||
height: 100vh; | ||
overflow: scroll; | ||
overflow: hidden scroll; | ||
width: 1px; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,7 +117,7 @@ h3 { | |
.content { | ||
flex: 1; | ||
height: 100vh; | ||
overflow: scroll; | ||
overflow: hidden scroll; | ||
width: 1px; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ nav .active { | |
text-align: left; | ||
max-width: 740px; | ||
margin: 0 auto; | ||
overflow: hidden; | ||
} | ||
|
||
p, div.p { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { plugin } from "./index"; | ||
import { compose, getAbsolutePath } from "./utils"; | ||
|
||
interface loaderOption { | ||
plugins: Array<plugin>; | ||
replace: (code: string) => string; | ||
} | ||
|
||
/** | ||
* 获取柯里化 cssLoader | ||
*/ | ||
export function getCssLoader({ plugins, replace }: loaderOption) { | ||
return (code: string, src: string = "", base: string): string => | ||
compose(plugins.map((plugin) => plugin.cssLoader))(replace ? replace(code) : code, src, base); | ||
} | ||
|
||
/** | ||
* 获取柯里化 jsLoader | ||
*/ | ||
export function getJsLoader({ plugins, replace }: loaderOption) { | ||
return (code: string, src: string = "", base: string): string => | ||
compose(plugins.map((plugin) => plugin.jsLoader))(replace ? replace(code) : code, src, base); | ||
} | ||
|
||
/** | ||
* 获取有效的 cssBeforeLoaders | ||
*/ | ||
export function getCssBeforeLoaders(plugins: Array<plugin>) { | ||
return plugins | ||
.map((plugin) => plugin.cssBeforeLoaders) | ||
.reduce((preLoaders, curLoaders) => preLoaders.concat(curLoaders), []) | ||
.filter((cssLoader) => typeof cssLoader === "object") | ||
.reverse(); | ||
} | ||
|
||
/** | ||
* 获取有效的 cssAfterLoaders | ||
*/ | ||
export function getCssAfterLoaders(plugins: Array<plugin>) { | ||
return plugins | ||
.map((plugin) => plugin.cssAfterLoaders) | ||
.reduce((preLoaders, curLoaders) => preLoaders.concat(curLoaders), []) | ||
.filter((afterLoader) => typeof afterLoader === "object"); | ||
} | ||
|
||
/** | ||
* 获取有效的 jsBeforeLoaders | ||
*/ | ||
export function getJsBeforeLoaders(plugins: Array<plugin>) { | ||
return plugins | ||
.map((plugin) => plugin.jsBeforeLoaders) | ||
.reduce((preLoaders, curLoaders) => preLoaders.concat(curLoaders), []) | ||
.filter((preLoader) => typeof preLoader === "object"); | ||
} | ||
|
||
/** | ||
* 获取有效的 jsAfterLoaders | ||
*/ | ||
export function getJsAfterLoaders(plugins: Array<plugin>) { | ||
return plugins | ||
.map((plugin) => plugin.jsAfterLoaders) | ||
.reduce((preLoaders, curLoaders) => preLoaders.concat(curLoaders), []) | ||
.filter((afterLoader) => typeof afterLoader === "object"); | ||
} | ||
|
||
/** | ||
* 转换子应用css内的相对地址成绝对地址 | ||
*/ | ||
function cssRelativePathResolve(code: string, src: string, base: string) { | ||
const baseUrl = src ? getAbsolutePath(src, base) : base; | ||
const urlReg = /(url\()([^)]*)(\))/g; | ||
return code.replace(urlReg, (_m, pre, url, post) => { | ||
const urlString = url.replace(/["']/g, ""); | ||
const absoluteUrl = getAbsolutePath(urlString, baseUrl); | ||
return pre + "'" + absoluteUrl + "'" + post; | ||
}); | ||
} | ||
|
||
export default { | ||
cssLoader: cssRelativePathResolve, | ||
}; |
Oops, something went wrong.