代码拉取完成,页面将自动刷新
同步操作将从 modstart-lib/ueditor-plus 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
"use strict";
module.exports = function (grunt) {
var fs = require("fs"),
Util = {
jsBasePath: "_src/",
parseBasePath: "_parse/",
cssBasePath: "themes/default/_css/",
fetchScripts: function (readFile, basePath) {
var sources = fs.readFileSync(readFile);
sources = /\[([^\]]+\.js'[^\]]+)\]/.exec(sources);
sources = sources[1]
.replace(/\/\/.*\n/g, "\n")
.replace(/'|"|\n|\t|\s/g, "");
sources = sources.split(",").filter(o => o);
sources.forEach(function (filepath, index) {
sources[index] = basePath + filepath;
});
return sources;
},
fetchStyles: function () {
var sources = fs.readFileSync(this.cssBasePath + "ueditor.css"),
filepath = null,
pattern = /@import\s+([^;]+)*;/g,
src = [];
while ((filepath = pattern.exec(sources))) {
src.push(this.cssBasePath + filepath[1].replace(/'|"/g, ""));
}
return src;
}
},
packageJson = grunt.file.readJSON("package.json"),
distDir = "dist/",
distMinDir = "dist-min/",
banner = "/*! " + packageJson.title + " v" + packageJson.version + "*/\n";
//init
(function () {
distDir = "dist/";
})();
var dateHash = (new Date()).getTime();
grunt.initConfig({
pkg: packageJson,
concat: {
js: {
options: {
banner: "/*!\n * " +
packageJson.title +
"\n * version: " +
packageJson.version +
"\n*/\n(function(){\n\n",
footer: "\n\n})();\n",
process: function (src, s) {
var filename = s.substr(s.indexOf("/") + 1);
return (
"// " + filename + "\n" + src.replace("/_css/", "/css/") + "\n"
);
}
},
src: Util.fetchScripts("_examples/editor_api.js", Util.jsBasePath),
dest: distDir + packageJson.name + ".all.js"
},
parse: {
options: {
banner: "/*!\n * " +
packageJson.title +
" parse\n * version: " +
packageJson.version +
"\n*/\n(function(){\n\n",
footer: "\n\n})();\n"
},
src: Util.fetchScripts("ueditor.parse.js", Util.parseBasePath),
dest: distDir + packageJson.name + ".parse.js"
},
css: {
src: Util.fetchStyles(),
dest: distDir + "themes/default/css/ueditor.css"
}
},
cssmin: {
options: {
banner: banner
},
files: {
cwd: distDir,
src: [
'**/*.css',
],
dest: distMinDir,
expand: true
}
},
uglify: {
options: {
banner: banner
},
files: {
cwd: distDir,
src: [
'**/*.js',
'!third-party/zeroclipboard/ZeroClipboard.js',
'!ueditor.all.js',
],
dest: distMinDir,
expand: true
},
},
copy: {
base: {
files: [
{
src: [
"*.html",
"themes/iframe.css",
"themes/default/dialogbase.css",
"themes/default/images/**",
"themes/default/exts/**",
// "themes/default/font/**",
"dialogs/**",
"lang/**",
"third-party/**",
"plugins/**",
],
dest: distDir
}
]
},
dist: {
files: [
{
cwd: distDir,
src: '**/*',
dest: distMinDir,
expand: true
}
]
},
demo: {
files: [
{
src: "_examples/completeDemo.html",
dest: distDir + "index.html"
}
]
},
},
transcoding: {
options: {
charset: 'utf-8'
},
src: [
distDir + "**/*.html",
distDir + "**/*.js",
distDir + "**/*.css",
distDir + "**/*.json",
]
},
replace: {
demo: {
src: distDir + "index.html",
overwrite: true,
replacements: [
{
from: /\.\.\//gi,
to: ""
},
{
from: "editor_api.js",
to: packageJson.name + ".all.js"
}
]
},
},
clean: {
build: {
src: [
distDir + ".DS_Store",
distDir + "**/.DS_Store",
distDir + ".git",
distDir + "**/.git"
]
}
}
});
grunt.loadNpmTasks("grunt-text-replace");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-cssmin");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-transcoding");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.registerTask("default", "UEditor build", function () {
var tasks = [
"concat",
"copy:base",
"copy:demo",
"replace:demo",
"copy:dist",
"uglify:files",
"cssmin:files",
"clean"
];
tasks.push("transcoding");
//config修改
updateConfigFile();
grunt.task.run(tasks);
});
function updateConfigFile() {
var filename = "ueditor.config.js",
file = grunt.file.read(filename);
//写入到dist
if (grunt.file.write(distDir + filename, file)) {
grunt.log.writeln("config file update success");
} else {
grunt.log.warn("config file update error");
}
}
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。