@moneko/core 3.1.5-beta.2 → 3.1.5-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,7 +9,9 @@ export default /**
|
|
|
9
9
|
* ```
|
|
10
10
|
*/class{// eslint-disable-next-line no-unused-vars
|
|
11
11
|
constructor(t){this.entryMatchCallback=t}apply(t){t.hooks.compilation.tap("AddEntryAttributeWebpackPlugin",a=>{// 通过最终的 webpack 配置的 plugins 属性,根据插件的 constructor.name 拿到 html-webpack-plugin 实例
|
|
12
|
-
let e=t.options.plugins.map(({constructor:t})=>t).find(t=>t&&"HtmlWebpackPlugin"===t.name);// .find(
|
|
12
|
+
let e=t.options.plugins.map(({constructor:t})=>t).find(t=>t&&"HtmlWebpackPlugin"===t.name);// .find(
|
|
13
|
+
// (plugin) => plugin instanceof HtmlWebpackPlugin,
|
|
14
|
+
// ) as typeof HtmlWebpackPlugin;
|
|
13
15
|
if(e){// 获取 html-webpack-plugin 所有的 hooks
|
|
14
16
|
let t=e.getHooks(a);// 在插入标签之前做些什么
|
|
15
17
|
t.alterAssetTagGroups.tap("AddEntryAttributeWebpackPlugin",t=>(// 拿到所有的标签,如果是 script 标签,并且满足我们的匹配函数,则将其 attributes['entry'] 设为 true
|
package/lib/module.config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as
|
|
2
|
-
auto:e=>{for(let s=0,
|
|
3
|
-
localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},$,f,{loader:"less-loader",options:{sourceMap:!!
|
|
4
|
-
|
|
1
|
+
import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as o,PUBLICPATH as t}from"./config.js";import{hasPkg as r}from"./has-pkg.js";import l from"./modify-vars.js";import a from"./paths.js";import{FRAMEWORK as i,isDev as n,isMicro as c}from"./process-env.js";import m from"./swcrc.js";import p from"./tsloader.config.js";import{resolveNodeModulesPath as d,resolveProgramPath as u}from"./utils.js";let f={loader:`${a.corePath}/loader/css-unicode.cjs`},x=c?t:"../",y={loader:e.loader,options:{publicPath:"/"!==x?x:"../"}},$=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};n&&(y="style-loader");let g=[...o.cssModules,`@moneko/${i}`,"neko-ui"].map(d),j=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(u)],v=["components","example","mock","site","src","server"].map(u),h=[y,n&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!n}},{loader:"css-loader",options:{modules:{// 根据文件名觉得是否启用cssModules | 排除 node_modules 和 *global.css 和 *global.less
|
|
2
|
+
auto:e=>{for(let s=0,o=g.length;s<o;s++)if(e&&e?.includes(g[s]))return/(.*(?<!\.?global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c)ss)$)/i.test(e)},// localIdentName: isDev ? '[path][name]__[local]' : '[hash:base64]',
|
|
3
|
+
localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},$,f,{loader:"less-loader",options:{sourceMap:!!o.sourceMap,lessOptions:{modifyVars:l,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:j}}].filter(Boolean),w={loader:"tsc"===o.compiler?"ts-loader":"swc-loader",options:"tsc"===o.compiler?p:m(n)},I=v.concat(o.rulesInclude?.media?.map(d)||[]),b=v.concat(o.rulesInclude?.fonts?.map(d)||[]),k=v.concat(o.rulesInclude?.less?.map(d)||[]),O=v.concat(o.rulesInclude?.css?.map(d)||[]),B=v.concat(o.rulesInclude?.js?.map(d)||[]),L=v.concat(o.rulesInclude?.wasm?.map(d)||[]),M={rules:[{resourceQuery:/raw/i,type:"asset/source"},{test:/\.mdx?$/i,include:[u("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:`${a.corePath}/loader/frontmatter.cjs`}]},{oneOf:[{test:/\.wasm$/i,// type: 'webassembly/async',
|
|
4
|
+
type:"asset/resource",include:L},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:I},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>s("string"!=typeof e?e.toString():e)},include:I},{test:/\.(gif|png|jpe?g|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext][query]"},include:I},{test:/\.(eot|ttf|otf|woff|woff2)$/i,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:b},{test:/\.less$/i,use:h,include:k},{test:/\.css$/i,use:[y,"css-loader",$,f].filter(Boolean),include:O},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...o.prefixJsLoader,w].filter(Boolean),include:B},{test:/\.mdx?$/i,use:[...o.prefixJsLoader,w,{loader:"@mdx-js/loader",options:o.mdx}].filter(Boolean),include:v,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...o.moduleRules]};export default M;
|