代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/jodit 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const fs = require('fs');
const path = require('path');
const cwd = process.cwd();
const reg = /--([a-zA-Z]+)\s*=\s*(.*)/;
const args = {};
process.argv
.filter(a => reg.test(a))
.forEach(c => {
const res = reg.exec(c);
args[res[1]] = res[2];
if (args[res[1]] === 'true') {
args[res[1]] = true;
}
if (args[res[1]] === 'false') {
args[res[1]] = false;
}
});
const config = require(path.resolve(cwd, './webpack.config'))(
[],
{
es: 'es5',
isTest: true,
...args
},
cwd
);
const compression = require('compression');
const app = new (require('express'))();
app.use(compression());
const port = args.port || 2000;
const compiler = webpack(config);
app.use(webpackDevMiddleware(compiler));
app.use(webpackHotMiddleware(compiler));
app.get('/', (req, res) => {
if (fs.existsSync(cwd + '/test.html')) {
res.sendFile(cwd + '/test.html');
} else {
res.sendFile(cwd + '/index.html');
}
});
app.get('/*.js', (req, res) => {
res.sendFile(cwd + '/' + req.url);
});
app.get('/icons.html', (req, res) => {
res.sendFile(cwd + '/icons.html');
});
app.get('/test.html', (req, res) => {
res.sendFile(cwd + '/test.html');
});
app.get('/fake.html', (req, res) => {
res.sendFile(cwd + '/fake.html');
});
app.get('/build/*.*', (req, res) => {
const filename = cwd + '/' + req.url;
if (fs.existsSync(filename)) {
res.sendFile(filename);
} else {
res.status(404).send('Not Found');
}
});
app.use('/node_modules', require('express').static(cwd + '/node_modules'));
app.use('/test', require('express').static(cwd + '/test'));
app.use('/app.css', require('express').static(cwd + '/app.css'));
app.use(
'/examples/download.jpg',
require('express').static(cwd + '/examples/download.jpg')
);
app.listen(port, function (error) {
if (error) {
console.error(error);
} else {
console.info(
'==> Listening on port %s. Open up http://localhost:%s/ in your browser.',
port,
port
);
}
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。