lvyjs 0.2.6 → 0.2.7

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.
package/bin/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+
2
3
  import { fork } from 'child_process'
3
4
  import { join, dirname, relative } from 'path'
4
5
  import { fileURLToPath } from 'node:url'
@@ -7,10 +8,8 @@ const args = [...process.argv.slice(2)]
7
8
  const currentFilePath = fileURLToPath(import.meta.url)
8
9
  const currentDirPath = dirname(currentFilePath)
9
10
  const pkgFilr = join(currentDirPath, '../package.json')
10
-
11
11
  const jsFile = join(currentDirPath, '../lib/index.js')
12
12
  const jsdir = relative(process.cwd(), jsFile)
13
-
14
13
  let tsxDir = join(currentDirPath, '../../tsx/dist/cli.mjs')
15
14
  if (!existsSync(tsxDir)) {
16
15
  tsxDir = join(currentDirPath, '../node_modules/tsx/dist/cli.mjs')
@@ -18,8 +17,10 @@ if (!existsSync(tsxDir)) {
18
17
  if (!existsSync(tsxDir)) {
19
18
  tsxDir = join(process.cwd(), 'node_modules/tsx/dist/cli.mjs')
20
19
  }
20
+ if (!existsSync(tsxDir)) {
21
+ new Error('无法搜寻tsx')
22
+ }
21
23
 
22
- // 启动模式
23
24
  if (args.includes('build')) {
24
25
  const argsx = args.filter(arg => arg !== 'build')
25
26
  const msg = fork(tsxDir, [jsdir, '--lvy-build', ...argsx], {
package/lib/config.js CHANGED
@@ -1,4 +1,17 @@
1
1
  const assetsReg = /\.(png|jpg|jpeg|gif|svg|webp|ico)$/;
2
2
  const cssReg = /\.(css|scss|less|sass|less)$/;
3
+ /**
4
+ *
5
+ * @param val
6
+ * @returns
7
+ */
8
+ const createAlias = val => {
9
+ const alias = {};
10
+ // 遍历 entries 数组
11
+ val.entries.forEach(entry => {
12
+ alias[entry.find] = entry.replacement;
13
+ });
14
+ return alias;
15
+ };
3
16
 
4
- export { assetsReg, cssReg };
17
+ export { assetsReg, createAlias, cssReg };
package/lib/content.js ADDED
@@ -0,0 +1,52 @@
1
+ import { join } from 'path';
2
+ import crypto from 'node:crypto';
3
+
4
+ /**
5
+ * @param inputPath
6
+ * @returns
7
+ */
8
+ const convertPath = (inputPath) => {
9
+ return ['win32'].includes(process.platform) ? inputPath : inputPath.replace(/\\/g, '/');
10
+ };
11
+ /**
12
+ * 生成模块内容
13
+ * @param {string} relativePath 相对路径
14
+ */
15
+ const generateModuleContent = (relativePath) => {
16
+ const contents = [
17
+ `const reg = ['win32'].includes(process.platform) ? /^file:\\/\\/\\// : /^file:\\/\\// ;`,
18
+ `const fileUrl = import.meta.resolve('${convertPath(relativePath)}').replace(reg, '');`,
19
+ 'export default fileUrl;'
20
+ ].join('\n');
21
+ return contents;
22
+ };
23
+ const getRandomName = (str) => {
24
+ // 使用 MD5 算法创建哈希对象
25
+ const hash = crypto.createHash('md5');
26
+ // 更新哈希对象内容
27
+ hash.update(str);
28
+ return hash.digest('hex');
29
+ };
30
+ const chache = {};
31
+ /**
32
+ *
33
+ * @param fileUrl
34
+ * @returns
35
+ */
36
+ const generateCSSModuleContent = (pathURL) => {
37
+ const fileName = getRandomName(pathURL);
38
+ const outputFileURL = convertPath(join(process.cwd(), 'node_modules', 'lvyjs', 'assets', `${fileName}.css`));
39
+ if (!chache[pathURL]) {
40
+ global.lvyWorkerProt.postMessage({
41
+ type: 'CSS_MODULE_GENERATED',
42
+ payload: {
43
+ from: pathURL,
44
+ to: outputFileURL
45
+ }
46
+ });
47
+ chache[pathURL] = true;
48
+ }
49
+ return `export default "${outputFileURL}";`;
50
+ };
51
+
52
+ export { generateCSSModuleContent, generateModuleContent };
@@ -6,7 +6,7 @@ import crypto from 'node:crypto';
6
6
  * @returns
7
7
  */
8
8
  const convertPath = (inputPath) => {
9
- return process.platform === 'win32' ? inputPath.replace(/\\/g, '/') : inputPath;
9
+ return ['win32'].includes(process.platform) ? inputPath : inputPath.replace(/\\/g, '/');
10
10
  };
11
11
  /**
12
12
  * 生成模块内容
@@ -14,13 +14,8 @@ const convertPath = (inputPath) => {
14
14
  */
15
15
  const generateModuleContent = (relativePath) => {
16
16
  const contents = [
17
- 'const createUrl = (basePath, path) => {',
18
- "const platform = ['linux', 'android', 'darwin'];",
19
- 'const T = platform.includes(process.platform);',
20
- 'const reg = T ? /^file:\\/\\// : /^file:\\/\\/\\//;',
21
- "return new URL(path, basePath).href.replace(reg, '');",
22
- '};',
23
- `const fileUrl = createUrl(import.meta.url, '${convertPath(relativePath)}');`,
17
+ `const reg = ['win32'].includes(process.platform) ? /^file:\\/\\/\\// : /^file:\\/\\// ;`,
18
+ `const fileUrl = import.meta.resolve('${convertPath(relativePath)}').replace(reg, '');`,
24
19
  'export default fileUrl;'
25
20
  ].join('\n');
26
21
  return contents;
package/lib/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export { Options, defineConfig, getOptions, initConfig, usePlugin } from './store.js';
2
2
  export { buildAndRun, buildJS } from './rullup/index.js';
3
- export { ESBuild } from './esbuild/index.js';
package/lib/index.js CHANGED
@@ -2,7 +2,6 @@ import { buildAndRun } from './rullup/index.js';
2
2
  export { buildJS } from './rullup/index.js';
3
3
  import { initConfig } from './store.js';
4
4
  export { defineConfig, getOptions, usePlugin } from './store.js';
5
- export { ESBuild } from './esbuild/index.js';
6
5
 
7
6
  /**
8
7
  * @param input
package/lib/loader.d.ts CHANGED
@@ -3,16 +3,27 @@ import { MessagePort } from 'worker_threads';
3
3
  declare global {
4
4
  var lvyWorkerProt: MessagePort;
5
5
  }
6
+ /**
7
+ *
8
+ * @param param0
9
+ */
6
10
  declare function initialize({ port, lvyConfig }: {
7
11
  port: any;
8
12
  lvyConfig: any;
9
13
  }): Promise<void>;
14
+ /**
15
+ * @param specifier
16
+ * @param context
17
+ * @param nextResolve
18
+ * @returns
19
+ */
20
+ declare function resolve(specifier: any, context: any, nextResolve: any): Promise<any>;
10
21
  /**
11
22
  * @param url
12
23
  * @param context
13
24
  * @param defaultLoad
14
25
  * @returns
15
26
  */
16
- declare const load: (url: any, context: any, defaultLoad: any) => Promise<any>;
27
+ declare const load: (url: any, context: any, nextLoad: any) => any;
17
28
 
18
- export { initialize, load };
29
+ export { initialize, load, resolve };
package/lib/loader.js CHANGED
@@ -1,31 +1,75 @@
1
- import { ESBuild } from './esbuild/index.js';
1
+ import { generateModuleContent, generateCSSModuleContent } from './content.js';
2
2
 
3
3
  const platform = ['win32'].includes(process.platform);
4
4
  const reg = platform ? /^file:\/\/\// : /^file:\/\//;
5
5
  const nodeReg = /(node_modules|node_|node:)/;
6
- const jsReg = /\.(js|ts|jsx|tsx)$/;
6
+ /**
7
+ *
8
+ * @param param0
9
+ */
7
10
  async function initialize({ port, lvyConfig }) {
8
11
  global.lvyConfig = lvyConfig;
9
12
  global.lvyWorkerProt = port;
10
13
  }
14
+ /**
15
+ * @param specifier
16
+ * @param context
17
+ * @param nextResolve
18
+ * @returns
19
+ */
20
+ async function resolve(specifier, context, nextResolve) {
21
+ const { parentURL = null } = context;
22
+ if (!global.lvyConfig?.alias) {
23
+ global.lvyConfig.alias = {};
24
+ }
25
+ if (global.lvyConfig.alias?.entries) {
26
+ for (const { find, replacement } of global.lvyConfig.alias?.entries) {
27
+ if (specifier.startsWith(find)) {
28
+ const url = specifier.replace(find, replacement);
29
+ return nextResolve(specifier, {
30
+ ...context,
31
+ parentURL: parentURL ? new URL(url, parentURL).href : new URL(url).href
32
+ });
33
+ }
34
+ }
35
+ }
36
+ return nextResolve(specifier, context);
37
+ }
11
38
  /**
12
39
  * @param url
13
40
  * @param context
14
41
  * @param defaultLoad
15
42
  * @returns
16
43
  */
17
- const load = async (url, context, defaultLoad) => {
44
+ const load = (url, context, nextLoad) => {
18
45
  if (nodeReg.test(url)) {
19
- return defaultLoad(url, context);
46
+ return nextLoad(url, context);
47
+ }
48
+ const urls = url.split('?');
49
+ const baseURL = urls[0];
50
+ // 得到静态资源。转为普通的文件引用。
51
+ if (!global.lvyConfig.assets) {
52
+ global.lvyConfig.assets = {};
53
+ }
54
+ // 匹配静态资源
55
+ if (global.lvyConfig.assets?.filter && global.lvyConfig.assets?.filter.test(baseURL)) {
56
+ const code = generateModuleContent(baseURL.replace(reg, ''));
57
+ return nextLoad(baseURL, {
58
+ format: 'module',
59
+ source: code
60
+ });
61
+ }
62
+ if (!global.lvyConfig.styles) {
63
+ global.lvyConfig.styles = {};
20
64
  }
21
- if (!jsReg.test(url)) {
22
- return defaultLoad(url, context);
65
+ if (global.lvyConfig.styles?.filter && global.lvyConfig.styles?.filter.test(baseURL)) {
66
+ const code = generateCSSModuleContent(baseURL.replace(reg, ''));
67
+ return nextLoad(baseURL, {
68
+ format: 'module',
69
+ source: code
70
+ });
23
71
  }
24
- const code = await ESBuild(url.replace(reg, ''));
25
- return defaultLoad(url, {
26
- format: 'module',
27
- source: code
28
- });
72
+ return nextLoad(url, context);
29
73
  };
30
74
 
31
- export { initialize, load };
75
+ export { initialize, load, resolve };
package/lib/main.js CHANGED
@@ -15,7 +15,6 @@ port1.on('message', msg => {
15
15
  cache[from] = true;
16
16
  }
17
17
  }
18
- else if (msg.type == 'JS_MODULE_GENERATED') ;
19
18
  });
20
19
  // port1.unref()
21
20
  module.register('./loader.js', {
package/lib/postcss.js CHANGED
@@ -10,6 +10,12 @@ const config = {
10
10
  less: null,
11
11
  scss: null
12
12
  };
13
+ /**
14
+ *
15
+ * @param configPath
16
+ * @param typing
17
+ * @returns
18
+ */
13
19
  const loadPostcssConfig = (configPath, typing) => {
14
20
  if (config[typing]) {
15
21
  return {
@@ -100,21 +106,24 @@ const loadPostcssConfig = (configPath, typing) => {
100
106
  plugins: config[typing]
101
107
  };
102
108
  };
109
+ /**
110
+ *
111
+ * @param inputPath
112
+ * @param outputPath
113
+ * @returns
114
+ */
103
115
  const postCSS = (inputPath, outputPath) => {
104
116
  const configPath = join(process.cwd(), 'postcss.config.cjs');
105
117
  let typing = 'css';
106
118
  let parser = undefined;
107
119
  if (/\.sass$/.test(inputPath)) {
108
120
  typing = 'sass';
109
- // parser = require('postcss-sass')
110
121
  }
111
122
  else if (/\.less$/.test(inputPath)) {
112
123
  typing = 'less';
113
- // parser = require('postcss-less')
114
124
  }
115
125
  else if (/\.scss$/.test(inputPath)) {
116
126
  typing = 'scss';
117
- // parser = require('postcss-scss')
118
127
  }
119
128
  const postcssConfig = loadPostcssConfig(configPath, 'css');
120
129
  if (!postcssConfig)
@@ -8,6 +8,7 @@ import { getScriptFiles } from './utils/files.js';
8
8
  import alias from '@rollup/plugin-alias';
9
9
  import { rollupStylesCSSImport } from './plugins/loader-css.js';
10
10
  import { rollupAssets } from './plugins/loader-files.js';
11
+ import { createAlias } from '../config.js';
11
12
 
12
13
  /**
13
14
  * 用于忽略警告
@@ -44,16 +45,8 @@ const buildJS = async (inputs) => {
44
45
  if (typeof global.lvyConfig?.styles !== 'boolean') {
45
46
  if (!global.lvyConfig.alias)
46
47
  global.lvyConfig.alias = {};
47
- const newAlias = val => {
48
- const alias = {};
49
- // 遍历 entries 数组
50
- val.entries.forEach(entry => {
51
- alias[entry.find] = entry.replacement;
52
- });
53
- return alias;
54
- };
55
48
  plugins.push(styles({
56
- alias: newAlias(global.lvyConfig?.alias),
49
+ alias: createAlias(global.lvyConfig?.alias),
57
50
  mode: ['inject', () => '']
58
51
  }));
59
52
  plugins.push(rollupStylesCSSImport(global.lvyConfig.styles));
@@ -99,14 +92,16 @@ const buildJS = async (inputs) => {
99
92
  }
100
93
  }
101
94
  const RollupOptions = global.lvyConfig?.build?.RollupOptions ?? {};
102
- const OutputOptions = global.lvyConfig?.build?.OutputOptions ?? [];
95
+ const plg = await RollupOptions?.plugins;
96
+ const pl = plg && typeof plg != 'boolean' ? plg : [];
103
97
  // build
104
98
  const bundle = await rollup({
105
99
  input: inputs,
106
- plugins: [...plugins],
107
100
  onwarn: onwarn,
108
- ...RollupOptions
101
+ ...RollupOptions,
102
+ plugins: Array.isArray(pl) ? [...plugins, ...pl] : pl
109
103
  });
104
+ const OutputOptions = global.lvyConfig?.build?.OutputOptions ?? [];
110
105
  // 写入输出文件
111
106
  await bundle.write({
112
107
  dir: 'lib',
@@ -43,15 +43,11 @@ const rollupStylesCSSImport = (options) => {
43
43
  // 内容
44
44
  source: csscode
45
45
  });
46
- const contents = `
47
- const createUrl = () => {
48
- const platform = ['linux', 'android', 'darwin'];
49
- const T = platform.includes(process.platform);
50
- const reg = T ? /^file:\\/\\// : /^file:\\/\\/\\//
51
- return import.meta.ROLLUP_FILE_URL_${refeId}.replace(reg, '')
52
- };
53
- export default createUrl();
54
- `;
46
+ const contents = [
47
+ `const reg = ['win32'].includes(process.platform) ? /^file:\\/\\/\\// : /^file:\\/\\// ;`,
48
+ `const fileUrl = import.meta.ROLLUP_FILE_URL_${refeId}.replace(reg, '');`,
49
+ 'export default fileUrl;'
50
+ ].join('\n');
55
51
  return contents;
56
52
  }
57
53
  };
@@ -22,16 +22,12 @@ const rollupAssets = (options) => {
22
22
  name: basename(id),
23
23
  source: readFileSync(id)
24
24
  });
25
- const content = [
26
- 'const createUrl = () => {',
27
- "const platform = ['linux', 'android', 'darwin'];",
28
- 'const T = platform.includes(process.platform);',
29
- 'const reg = T ? /^file:\\/\\// : /^file:\\/\\/\\//',
30
- 'return import.meta.ROLLUP_FILE_URL_' + referenceId + ".replace(reg, '')",
31
- '};',
32
- 'export default createUrl();'
25
+ const contents = [
26
+ `const reg = ['win32'].includes(process.platform) ? /^file:\\/\\/\\// : /^file:\\/\\// ;`,
27
+ `const fileUrl = import.meta.ROLLUP_FILE_URL_${referenceId}.replace(reg, '');`,
28
+ 'export default fileUrl;'
33
29
  ].join('\n');
34
- return content;
30
+ return contents;
35
31
  }
36
32
  }
37
33
  };
package/lib/server.js ADDED
@@ -0,0 +1,11 @@
1
+ import Koa from 'koa';
2
+ import KoaStatic from 'koa-static';
3
+
4
+ const app = new Koa();
5
+ // 使用 koa-static 中间件来提供静态文件
6
+ app.use(KoaStatic(process.cwd()));
7
+ // 设定端口并启动服务器
8
+ const PORT = 8989;
9
+ app.listen(8989, () => {
10
+ console.log(`Server running at http://localhost:${PORT}`);
11
+ });
package/lib/store.d.ts CHANGED
@@ -1,12 +1,8 @@
1
1
  import { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
2
2
  import { RollupTypescriptOptions } from '@rollup/plugin-typescript';
3
- import { SameShape, BuildOptions } from 'esbuild';
4
3
  import { RollupOptions, OutputOptions } from 'rollup';
4
+ import { Alias } from './typing.js';
5
5
 
6
- interface Alias {
7
- find: string | RegExp;
8
- replacement: string;
9
- }
10
6
  type Options = {
11
7
  /**
12
8
  * 配置调整机及其回调插件
@@ -36,15 +32,6 @@ type Options = {
36
32
  */
37
33
  filter?: RegExp;
38
34
  } | false;
39
- /**
40
- * 运行时配置
41
- */
42
- esbuild?: {
43
- /**
44
- *
45
- */
46
- options?: SameShape<BuildOptions, BuildOptions>;
47
- };
48
35
  /**
49
36
  * 打包时配置
50
37
  */
@@ -0,0 +1,6 @@
1
+ interface Alias {
2
+ find: string;
3
+ replacement: string;
4
+ }
5
+
6
+ export type { Alias };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lvyjs",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "tsx compile script",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",
@@ -13,14 +13,12 @@
13
13
  "@rollup/plugin-typescript": "^11.1.6",
14
14
  "@rollup/pluginutils": "^5.1.3",
15
15
  "autoprefixer": "^10.4.20",
16
- "esbuild": "^0.24.0",
17
16
  "postcss": "^8.4.47",
18
17
  "postcss-import": "^16.1.0",
19
18
  "postcss-url": "^10.1.3",
20
19
  "rollup": "^4.18.1",
21
20
  "rollup-plugin-dts": "^6.1.1",
22
21
  "rollup-plugin-styles": "^4.0.0",
23
- "tailwindcss": "^3.4.3",
24
22
  "tsx": "^4.19.1",
25
23
  "typescript": "^5.5.3"
26
24
  },
@@ -1,4 +0,0 @@
1
- const assetsReg = /\.(png|jpg|jpeg|gif|svg|webp|ico)$/
2
- const cssReg = /\.(css|scss|less|sass|less)$/
3
-
4
- export { assetsReg, cssReg }
@@ -1,8 +0,0 @@
1
- /**
2
- *
3
- * @param input
4
- * @returns
5
- */
6
- declare const ESBuild: (input: string) => Promise<string>;
7
-
8
- export { ESBuild };
@@ -1,64 +0,0 @@
1
- import esbuild from 'esbuild';
2
- import { esBuildCSS } from './plugins/css.js';
3
- import { esBuildAlias } from './plugins/alias.js';
4
- import { esBuildAsstes } from './plugins/Asstes.js';
5
-
6
- // 插件
7
- const plugins = [];
8
- /**
9
- *
10
- */
11
- const initPlugins = () => {
12
- if (typeof global.lvyConfig?.alias != 'boolean') {
13
- plugins.push(esBuildAlias(global.lvyConfig.alias));
14
- }
15
- if (typeof global.lvyConfig?.assets != 'boolean') {
16
- plugins.push(esBuildAsstes(global.lvyConfig.assets));
17
- }
18
- if (typeof global.lvyConfig?.styles != 'boolean') {
19
- plugins.push(esBuildCSS(global.lvyConfig?.styles ?? {}));
20
- }
21
- };
22
- /**
23
- *
24
- * @param input
25
- * @returns
26
- */
27
- const ESBuild = async (input) => {
28
- // 如果没有配置
29
- if (!global.lvyConfig)
30
- global.lvyConfig = {};
31
- if (!global.lvyConfig.esbuild)
32
- global.lvyConfig.esbuild = {};
33
- // 没有插件时,检查是否有可用插件。
34
- if (plugins.length === 0) {
35
- // init plugisn
36
- await initPlugins();
37
- }
38
- const options = global.lvyConfig?.esbuild?.options ?? {};
39
- const pl = options?.plugins ?? [];
40
- // 构建
41
- const result = await esbuild.build({
42
- // 入口文件
43
- entryPoints: [input],
44
- //
45
- bundle: true,
46
- // 平台
47
- platform: 'node',
48
- // 输出格式
49
- format: 'esm',
50
- // 不写入文件
51
- write: false,
52
- // 忽略所有外部依赖
53
- external: ['*'],
54
- ...options,
55
- plugins: [...plugins, ...pl]
56
- });
57
- if (!result.outputFiles) {
58
- return '';
59
- }
60
- // 返回结果
61
- return result.outputFiles.map(file => new TextDecoder().decode(file.contents)).join('\n');
62
- };
63
-
64
- export { ESBuild };
@@ -1,26 +0,0 @@
1
- import { assetsReg } from '../../config.js';
2
- import { generateModuleContent } from '../utils/content.js';
3
-
4
- /**
5
- *
6
- * @param param0
7
- */
8
- const esBuildAsstes = (optoins) => {
9
- // 默认配置
10
- const filter = optoins?.filter ?? assetsReg;
11
- // 返回插件
12
- return {
13
- name: 'assets',
14
- setup(build) {
15
- build.onLoad({ filter }, args => {
16
- const content = generateModuleContent(args.path);
17
- return {
18
- contents: content,
19
- loader: 'js'
20
- };
21
- });
22
- }
23
- };
24
- };
25
-
26
- export { esBuildAsstes };
@@ -1,44 +0,0 @@
1
- import { assetsReg, cssReg } from '../../config.js';
2
- import { resolve } from 'path';
3
-
4
- /**
5
- * esbuild alias 插件
6
- * @param alias 配置对象
7
- * @returns 插件
8
- */
9
- const esBuildAlias = (alias) => {
10
- const entries = alias?.entries;
11
- let assets = null;
12
- if (typeof global.lvyConfig?.assets != 'boolean') {
13
- assets = global.lvyConfig?.assets?.filter ?? assetsReg;
14
- }
15
- let styles = null;
16
- if (typeof global.lvyConfig?.styles != 'boolean') {
17
- styles = global.lvyConfig?.styles?.filter ?? cssReg;
18
- }
19
- return {
20
- name: 'alias',
21
- setup(build) {
22
- if (entries) {
23
- build.onResolve({ filter: /.*/ }, args => {
24
- const url = args.path;
25
- const resolveDir = args.resolveDir;
26
- if (assets?.test(url) || styles?.test(url)) {
27
- for (const { find, replacement } of entries) {
28
- if ((find instanceof RegExp && find.test(url)) ||
29
- (typeof find === 'string' && url.startsWith(find))) {
30
- let resolvedPath = url.replace(find, replacement);
31
- return { path: resolvedPath };
32
- }
33
- }
34
- return {
35
- path: resolve(resolveDir, url)
36
- };
37
- }
38
- });
39
- }
40
- }
41
- };
42
- };
43
-
44
- export { esBuildAlias };
@@ -1,27 +0,0 @@
1
- import { generateCSSModuleContent } from '../utils/content.js';
2
- import { cssReg } from '../../config.js';
3
-
4
- /**
5
- * css资源处理插件
6
- * @param param0
7
- * @returns
8
- */
9
- const esBuildCSS = (optoins) => {
10
- const filter = optoins?.filter || cssReg;
11
- // 返回插件
12
- return {
13
- name: 'css-loader',
14
- setup(build) {
15
- // 加载 CSS/SCSS 文件
16
- build.onLoad({ filter }, args => {
17
- const contents = generateCSSModuleContent(args.path);
18
- return {
19
- contents: contents,
20
- loader: 'js'
21
- };
22
- });
23
- }
24
- };
25
- };
26
-
27
- export { esBuildCSS };
@@ -1,4 +0,0 @@
1
- const assetsReg = /\.(png|jpg|jpeg|gif|svg|webp|ico)$/
2
- const cssReg = /\.(css|scss|less|sass|less)$/
3
-
4
- export { assetsReg, cssReg }