feat: 修改 webpack配置文件

This commit is contained in:
tackchen 2020-12-16 13:37:28 +08:00
parent 78a8be2fb9
commit 98cf22b47e
4 changed files with 47 additions and 59 deletions

20
helper/all/index.d.ts vendored
View File

@ -36,15 +36,15 @@ declare interface DrawOption {
clear?: boolean; // 绘制前是否清空容器 默认为true
style?: { // 样式类
backgroundColor?: string, // 默认为#fff
showOutline?: boolean;//: true,
showCharacter?: boolean;//: true,
currentColor?: string;//: '#b44', // 仅在stroke模式下有效
length?: number;//: 60,
padding?: number;//: 5, // 数值, 默认 20。 画布的汉字和边缘之间的填充
outlineColor?: string;//: '#ddd', // 十六进制字符, 默认 '#DDD'。
strokeColor?: string;//: '#555', // 十六进制字符, 默认 '#555'。绘制每个笔划的颜色。
radicalColor?: string;//: null, // 十六进制字符, 默认 null。 如果存在偏旁部首数据,则在笔划中绘制偏旁部首的颜色。 如果没有设置,激光将绘制与其他笔划相同的颜色。
strokeFadeDuration?: number; //400
showOutline?: boolean;// : true,
showCharacter?: boolean;// : true,
currentColor?: string;// : '#b44', // 仅在stroke模式下有效
length?: number;// : 60,
padding?: number;// : 5, // 数值, 默认 20。 画布的汉字和边缘之间的填充
outlineColor?: string;// : '#ddd', // 十六进制字符, 默认 '#DDD'。
strokeColor?: string;// : '#555', // 十六进制字符, 默认 '#555'。绘制每个笔划的颜色。
radicalColor?: string;// : null, // 十六进制字符, 默认 null。 如果存在偏旁部首数据,则在笔划中绘制偏旁部首的颜色。 如果没有设置,激光将绘制与其他笔划相同的颜色。
strokeFadeDuration?: number; // 400
},
line?: { // 背景线条类
lineStraight?: boolean;// : true,
@ -159,7 +159,7 @@ export declare interface CnCharStatic {
transformTone(spell: string, tone?: boolean, type?: 'low' | 'up'): {
spell: string;
tone: toneType;
index: number;
index: number;
isTrans: boolean;
};
isCnChar(word: string): boolean;

View File

@ -3,15 +3,12 @@ const rename = require('gulp-rename');
const fs = require('fs');
const babel = require('gulp-babel');
const toc = require('gulp-markdown-toc');
let version = require('../package.json').version;
let files = [
'../npm/order/package.json',
'../npm/poly/package.json',
'../npm/trad/package.json',
'../npm/draw/package.json',
'../npm/idiom/package.json',
'../npm/xhy/package.json',
'../npm/radical/package.json',
const version = require('../package.json').version;
const plugins = ['order', 'poly', 'trad', 'draw', 'idiom', 'xhy', 'radical'];
const files = [
...plugins.map(plugin => `../npm/${plugin}/package.json`),
'../npm/cnchar/package.json',
'../npm/all/package.json',
'../npm/hanzi-util/package.json',
@ -20,14 +17,14 @@ let files = [
function modVersion () {
files.forEach(file => {
let pkg = require(file);
const pkg = require(file);
pkg.version = version;
fs.writeFile(file.substr(1), JSON.stringify(pkg, null, 4), 'utf8', (err) => {
if (err) throw err;
});
});
}
let depFiles = [
const depFiles = [
'../npm/all/package.json',
'../npm/hanzi-util/package.json',
'../npm/hanzi-util-base/package.json'
@ -35,9 +32,9 @@ let depFiles = [
function modDep () {
depFiles.forEach(file => {
let pkg = require(file);
let dep = pkg.dependencies;
for (let key in dep) {
const pkg = require(file);
const dep = pkg.dependencies;
for (const key in dep) {
if (key.substr(0, 6) === 'cnchar') {
dep[key] = '^' + version;
}
@ -56,50 +53,41 @@ function task () {
transEs6ByBabel();
}
function buildPluginGulpFiles (plugin) {
const path = `src/plugin/${plugin}/`;
return [`${path}dict/*.json`, `${path}types`, `${path}*.d.ts`];
}
function gulpPlugin (plugin) {
gulp.src(buildPluginGulpFiles(plugin))
.pipe(gulp.dest(`npm/${plugin}`));
}
function copyToNPM () {
gulp.src('helper/README.md')
const gulpReadme = gulp.src(['helper/README.md', 'LICENSE'])
.pipe(toc())
.pipe(gulp.dest('.'))
.pipe(gulp.dest('npm/cnchar'))
.pipe(gulp.dest('npm/order'))
.pipe(gulp.dest('npm/poly'))
.pipe(gulp.dest('npm/trad'))
.pipe(gulp.dest('npm/draw'))
.pipe(gulp.dest('npm/idiom'))
.pipe(gulp.dest('npm/radical'))
.pipe(gulp.dest('npm/xhy'));
gulp.src(['src/main/*.json', 'src/main/*.d.ts', 'LICENSE'])
.pipe(gulp.dest('npm/cnchar'));
gulp.src(['src/plugin/order/*.json', 'src/plugin/order/*.d.ts', 'LICENSE'])
.pipe(gulp.dest('npm/order'));
plugins.forEach(plugin => {
gulpReadme = gulpReadme.pipe(`npm/${plugin}`);
});
gulp.src(['src/plugin/poly/*.json', 'src/plugin/poly/*.d.ts', 'LICENSE'])
.pipe(gulp.dest('npm/poly'));
gulp.src(['src/main/dict/*.json', 'src/main/types', 'src/main/*.d.ts'])
.pipe(gulp.dest('npm/cnchar'));
plugins.forEach(plugin => {
gulpPlugin(plugin);
});
gulp.src(['src/plugin/trad/*.json', 'src/plugin/trad/*.d.ts', 'LICENSE'])
.pipe(gulp.dest('npm/trad'));
gulp.src(['src/plugin/draw/*.json', 'src/plugin/draw/*.d.ts', 'LICENSE'])
.pipe(gulp.dest('npm/draw'));
gulp.src(['src/plugin/idiom/*.json', 'src/plugin/idiom/*.d.ts', 'LICENSE'])
.pipe(gulp.dest('npm/idiom'));
gulp.src(['src/plugin/radical/*.json', 'src/plugin/radical/*.d.ts', 'LICENSE'])
.pipe(gulp.dest('npm/radical'));
gulp.src(['src/plugin/xhy/*.json', 'src/plugin/xhy/*.d.ts', 'LICENSE'])
.pipe(gulp.dest('npm/xhy'));
gulp.src(['src/main/*.d.ts', 'LICENSE'])
gulp.src(['src/main/*.d.ts', 'src/main/types'])
.pipe(gulp.dest('npm/hanzi-util-base'));
gulp.src(['helper/all/*.d.ts', 'LICENSE'])
gulp.src(['helper/all/*.d.ts'])
.pipe(gulp.dest('npm/all'))
.pipe(gulp.dest('npm/hanzi-util'));
}
function copyLatest () {
// gulp.src(`dist/*.${version}.min.js`)
// .pipe(rename(function (path) {

View File

@ -2,7 +2,7 @@ const version = require('../package.json').version;
const path = require('path');
const tool = require('../helper/tool');
tool.write('./src/main/version.js', 'module.exports = \'' + version + '\';');
tool.write('./src/main/version.ts', 'module.exports = \'' + version + '\';');
// module.exports = {
// entry: path.resolve('./', 'src/main/index.js'),
@ -22,7 +22,7 @@ tool.write('./src/main/version.js', 'module.exports = \'' + version + '\';');
module.exports = {
mode: 'production',
entry: path.resolve('./', 'src/main/index.js'),
entry: path.resolve('./', 'src/main/index.ts'),
output: {
path: path.resolve('./', 'npm/cnchar'),
filename: 'cnchar.min.js',

View File

@ -24,7 +24,7 @@ module.exports = (env) => {
const plugin = env.pluginname;
return {
mode: 'production',
entry: path.resolve('./', 'src/plugin/' + plugin + '/index.js'),
entry: path.resolve('./', 'src/plugin/' + plugin + '/index.ts'),
output: {
path: path.resolve('./', 'npm/' + plugin),
filename: 'cnchar.' + plugin + '.min.js',