更新配置,改为esm模式
parent
8f38302c01
commit
d31ec1287b
32
build.dev.js
32
build.dev.js
|
@ -1,18 +1,18 @@
|
|||
#! /usr/bin/env node
|
||||
|
||||
require('es.shim')
|
||||
import 'es.shim'
|
||||
import fs from 'iofs'
|
||||
import { parse, resolve } from 'path'
|
||||
import scss from 'sass'
|
||||
import chalk from 'chalk'
|
||||
import { transform } from 'esbuild'
|
||||
import chokidar from 'chokidar'
|
||||
|
||||
const { version } = JSON.parse(fs.cat('./package.json'))
|
||||
const sourceDir = resolve('./src')
|
||||
const buildDir = resolve('./dist')
|
||||
|
||||
const log = console.log
|
||||
const fs = require('iofs')
|
||||
const path = require('path')
|
||||
const scss = require('sass')
|
||||
const chokidar = require('chokidar')
|
||||
const chalk = require('chalk')
|
||||
const { transform } = require('esbuild')
|
||||
|
||||
const sourceDir = path.resolve(__dirname, 'src')
|
||||
const buildDir = path.resolve(__dirname, 'dist')
|
||||
|
||||
const VERSION = require('./package.json').version
|
||||
const BUILD_DATE = new Date().format()
|
||||
|
||||
const ESBUILD_OPTIONS = {
|
||||
|
@ -66,7 +66,7 @@ function mkWCFile({ style, html, js }) {
|
|||
|
||||
let name = ''
|
||||
|
||||
js = js.replace(/props = (\{\}|\{[\w\W]*?\n\s{2}?\})/, function(str) {
|
||||
js = js.replace(/props = (\{\}|\{[\w\W]*?\n\s{2}?\})/, function (str) {
|
||||
var attr = str
|
||||
.split(/\n+/)
|
||||
.slice(1, -1)
|
||||
|
@ -85,7 +85,7 @@ function mkWCFile({ style, html, js }) {
|
|||
})
|
||||
|
||||
js = fixImport(js)
|
||||
.replace(/export default class ([a-zA-Z0-9]+)/, function(s, m) {
|
||||
.replace(/export default class ([a-zA-Z0-9]+)/, function (s, m) {
|
||||
name = m
|
||||
return `${s} extends HTMLElement `
|
||||
})
|
||||
|
@ -117,7 +117,7 @@ function mkWCFile({ style, html, js }) {
|
|||
*
|
||||
* @authors yutent (yutent.io@gmail.com)
|
||||
* @date ${BUILD_DATE}
|
||||
* @version v${VERSION}
|
||||
* @version v${version}
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -154,7 +154,7 @@ chokidar
|
|||
let entry = file
|
||||
let output = file.replace('src/', 'dist/')
|
||||
|
||||
file = path.parse(entry)
|
||||
file = parse(entry)
|
||||
if (!file.ext || file.base === '.DS_Store' || file.base === 'var.scss') {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#! /usr/bin/env node
|
||||
|
||||
require('es.shim')
|
||||
import 'es.shim'
|
||||
import fs from 'iofs'
|
||||
import { parse, resolve } from 'path'
|
||||
import scss from 'sass'
|
||||
import chalk from 'chalk'
|
||||
import { transform } from 'esbuild'
|
||||
|
||||
const { version } = JSON.parse(fs.cat('./package.json'))
|
||||
const sourceDir = resolve('./src')
|
||||
const buildDir = resolve('./dist')
|
||||
|
||||
const log = console.log
|
||||
const fs = require('iofs')
|
||||
const path = require('path')
|
||||
const scss = require('sass')
|
||||
const chalk = require('chalk')
|
||||
const { transform } = require('esbuild')
|
||||
|
||||
const sourceDir = path.resolve(__dirname, 'src')
|
||||
const buildDir = path.resolve(__dirname, 'dist')
|
||||
|
||||
const VERSION = require('./package.json').version
|
||||
const BUILD_DATE = new Date().format()
|
||||
|
||||
const ESBUILD_OPTIONS = {
|
||||
|
@ -72,7 +72,7 @@ function mkWCFile({ style, html, js }) {
|
|||
html = html.replace(/[\n\r]+/g, ' ')
|
||||
html = html.replace(/\s+/g, ' ')
|
||||
|
||||
js = js.replace(/props = (\{\}|\{[\w\W]*?\n\s{2}?\})/, function(str) {
|
||||
js = js.replace(/props = (\{\}|\{[\w\W]*?\n\s{2}?\})/, function (str) {
|
||||
var attr = str
|
||||
.split(/\n+/)
|
||||
.slice(1, -1)
|
||||
|
@ -91,7 +91,7 @@ function mkWCFile({ style, html, js }) {
|
|||
})
|
||||
|
||||
js = fixImport(js)
|
||||
.replace(/export default class ([a-zA-Z0-9]+)/, function(s, m) {
|
||||
.replace(/export default class ([a-zA-Z0-9]+)/, function (s, m) {
|
||||
name = m
|
||||
return `${s} extends HTMLElement `
|
||||
})
|
||||
|
@ -124,7 +124,7 @@ function mkWCFile({ style, html, js }) {
|
|||
*
|
||||
* @authors yutent (yutent.io@gmail.com)
|
||||
* @date ${BUILD_DATE}
|
||||
* @version v${VERSION}
|
||||
* @version v${version}
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -166,7 +166,7 @@ fs.mkdir(buildDir)
|
|||
|
||||
let files = fs.ls(sourceDir, true)
|
||||
files = files.map(it => {
|
||||
let file = path.parse(it)
|
||||
let file = parse(it)
|
||||
if (!file.ext || file.base === '.DS_Store' || file.base === 'var.scss') {
|
||||
return null
|
||||
}
|
||||
|
|
10
package.json
10
package.json
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "@bytedo/wcui",
|
||||
"version": "1.0.5",
|
||||
"type": "module",
|
||||
"description": "基于wc开发的一套UI库, 面向未来, 面向electron",
|
||||
"scripts": {
|
||||
"start": "node ./build.dev.js",
|
||||
|
@ -11,11 +12,16 @@
|
|||
"url": "git+https://github.com/bytedo/wcui.git"
|
||||
},
|
||||
"main": "dist/",
|
||||
"keywords": ["web-components", "wc", "components", "yutent"],
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"wc",
|
||||
"components",
|
||||
"yutent"
|
||||
],
|
||||
"author": "yutent",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"chalk": "^3.0.0",
|
||||
"chalk": "^5.0.0",
|
||||
"chokidar": "^3.5.2",
|
||||
"es.shim": "^2.0.2",
|
||||
"iofs": "^1.5.2",
|
||||
|
|
Reference in New Issue