mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-21 11:24:20 +01:00
html: update webpack
This commit is contained in:
@@ -1,16 +1,14 @@
|
|||||||
const gulp = require('gulp'),
|
const { src, dest, task } = require("gulp");
|
||||||
clean = require('gulp-clean'),
|
const clean = require('gulp-clean');
|
||||||
inlinesource = require('gulp-inline-source');
|
const inlinesource = require('gulp-inline-source');
|
||||||
|
|
||||||
gulp.task('clean', function () {
|
task('clean', () => {
|
||||||
return gulp.src('dist', {read: false})
|
return src('dist', {read: false, allowEmpty: true})
|
||||||
.pipe(clean());
|
.pipe(clean());
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('inlinesource', function () {
|
task('default', () => {
|
||||||
return gulp.src('dist/index.html')
|
return src('dist/index.html')
|
||||||
.pipe(inlinesource())
|
.pipe(inlinesource())
|
||||||
.pipe(gulp.dest('../src/'));
|
.pipe(dest('../src/'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('default', ['inlinesource']);
|
|
||||||
@@ -2,10 +2,10 @@ import '../sass/app.scss';
|
|||||||
|
|
||||||
import { Terminal, ITerminalOptions, IDisposable } from 'xterm';
|
import { Terminal, ITerminalOptions, IDisposable } from 'xterm';
|
||||||
import * as fit from 'xterm/lib/addons/fit/fit'
|
import * as fit from 'xterm/lib/addons/fit/fit'
|
||||||
|
import * as Zmodem from 'zmodem.js/src/zmodem_browser';
|
||||||
|
|
||||||
import * as overlay from './overlay'
|
import * as overlay from './overlay'
|
||||||
import { Modal } from './zmodem'
|
import { Modal } from './zmodem'
|
||||||
import * as Zmodem from 'zmodem.js/src/zmodem_browser';
|
|
||||||
import * as urljoin from 'url-join';
|
|
||||||
|
|
||||||
Terminal.applyAddon(fit);
|
Terminal.applyAddon(fit);
|
||||||
Terminal.applyAddon(overlay);
|
Terminal.applyAddon(overlay);
|
||||||
@@ -29,7 +29,8 @@ declare let window: IWindowWithTerminal;
|
|||||||
const modal = new Modal();
|
const modal = new Modal();
|
||||||
const terminalContainer = document.getElementById('terminal-container');
|
const terminalContainer = document.getElementById('terminal-container');
|
||||||
const protocol = window.location.protocol === 'https:' ? 'wss://': 'ws://';
|
const protocol = window.location.protocol === 'https:' ? 'wss://': 'ws://';
|
||||||
const url = urljoin(protocol, window.location.host, window.location.pathname, 'ws', window.location.search);
|
const wsPath = window.location.pathname.endsWith('/') ? 'ws' : '/ws';
|
||||||
|
const url = [protocol, window.location.host, window.location.pathname, wsPath, window.location.search].join('');
|
||||||
const textDecoder = new TextDecoder();
|
const textDecoder = new TextDecoder();
|
||||||
const textEncoder = new TextEncoder();
|
const textEncoder = new TextEncoder();
|
||||||
|
|
||||||
@@ -153,7 +154,7 @@ let openWs = function() {
|
|||||||
// https://stackoverflow.com/a/27923937/1727928
|
// https://stackoverflow.com/a/27923937/1727928
|
||||||
window.addEventListener('resize', () => {
|
window.addEventListener('resize', () => {
|
||||||
clearTimeout(window.resizeTimeout);
|
clearTimeout(window.resizeTimeout);
|
||||||
window.resizeTimeout = setTimeout(() => term.fit(), 250);
|
window.resizeTimeout = <number><any>setTimeout(() => term.fit(), 250);
|
||||||
});
|
});
|
||||||
window.addEventListener('beforeunload', unloadCallback);
|
window.addEventListener('beforeunload', unloadCallback);
|
||||||
|
|
||||||
@@ -209,7 +210,7 @@ let openWs = function() {
|
|||||||
window.removeEventListener('beforeunload', unloadCallback);
|
window.removeEventListener('beforeunload', unloadCallback);
|
||||||
// 1000: CLOSE_NORMAL
|
// 1000: CLOSE_NORMAL
|
||||||
if (event.code !== 1000 && autoReconnect > 0) {
|
if (event.code !== 1000 && autoReconnect > 0) {
|
||||||
term.reconnectTimeout = setTimeout(openWs, autoReconnect * 1000);
|
term.reconnectTimeout = <number><any>setTimeout(openWs, autoReconnect * 1000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,35 +10,33 @@
|
|||||||
"author": "Shuanglei Tao <tsl0922@gmail.com>",
|
"author": "Shuanglei Tao <tsl0922@gmail.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "NODE_ENV=production webpack --config webpack.prod.js && gulp",
|
"build": "NODE_ENV=production npx wp --config webpack.prod.js && gulp",
|
||||||
"start": "gulp clean && webpack-serve webpack.dev.js"
|
"start": "gulp clean && npx webpack-dev-server --config webpack.dev.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"url-join": "^4.0.0",
|
|
||||||
"xterm": "^3.13.0",
|
"xterm": "^3.13.0",
|
||||||
"zmodem.js": "^0.1.9"
|
"zmodem.js": "^0.1.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"copy-webpack-plugin": "^4.5.1",
|
"copy-webpack-plugin": "^5.0.3",
|
||||||
"css-loader": "^0.28.8",
|
"css-loader": "^2.1.1",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^4.0.2",
|
||||||
"gulp-clean": "^0.4.0",
|
"gulp-clean": "^0.4.0",
|
||||||
"gulp-inline-source": "^3.1.0",
|
"gulp-inline-source": "^4.0.0",
|
||||||
"html-webpack-inline-source-plugin": "^0.0.10",
|
"html-webpack-inline-source-plugin": "^0.0.10",
|
||||||
"html-webpack-plugin": "^3.2.0",
|
"html-webpack-plugin": "^3.2.0",
|
||||||
"http-proxy-middleware": "^0.18.0",
|
"mini-css-extract-plugin": "^0.6.0",
|
||||||
"koa-connect": "^2.0.1",
|
"node-sass": "^4.12.0",
|
||||||
"mini-css-extract-plugin": "^0.4.0",
|
"optimize-css-assets-webpack-plugin": "^5.0.1",
|
||||||
"node-sass": "^4.7.2",
|
"sass-loader": "^7.1.0",
|
||||||
"optimize-css-assets-webpack-plugin": "^4.0.1",
|
"style-loader": "^0.23.1",
|
||||||
"sass-loader": "^6.0.6",
|
"terser-webpack-plugin": "^1.2.4",
|
||||||
"style-loader": "^0.19.1",
|
|
||||||
"ts-loader": "^6.0.0",
|
"ts-loader": "^6.0.0",
|
||||||
"typescript": "^3.4.5",
|
"typescript": "^3.4.5",
|
||||||
"uglifyjs-webpack-plugin": "^1.2.5",
|
"webpack": "^4.31.0",
|
||||||
"webpack": "^4.6.0",
|
"webpack-cli": "^3.3.2",
|
||||||
"webpack-cli": "^2.1.2",
|
"webpack-dev-server": "^3.3.1",
|
||||||
"webpack-merge": "^4.1.2",
|
"webpack-merge": "^4.2.1",
|
||||||
"webpack-serve": "^0.3.2"
|
"webpack-nano": "^0.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|||||||
const devMode = process.env.NODE_ENV !== 'production';
|
const devMode = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: './js/app.ts',
|
entry: {
|
||||||
|
app: './js/app.ts'
|
||||||
|
},
|
||||||
output: {
|
output: {
|
||||||
path: __dirname + '/dist',
|
path: __dirname + '/dist',
|
||||||
filename: devMode ? '[name].js' : '[name].[hash].js',
|
filename: devMode ? '[name].js' : '[name].[hash].js',
|
||||||
@@ -40,5 +42,5 @@ module.exports = {
|
|||||||
performance : {
|
performance : {
|
||||||
hints : false
|
hints : false
|
||||||
},
|
},
|
||||||
devtool: 'inline-source-map',
|
devtool: 'source-map',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,31 +1,24 @@
|
|||||||
|
const path = require('path');
|
||||||
const merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
const convert = require('koa-connect');
|
|
||||||
const proxy = require('http-proxy-middleware');
|
|
||||||
const config = require('./webpack.config.js');
|
const config = require('./webpack.config.js');
|
||||||
|
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
|
||||||
module.exports = merge(config, {
|
module.exports = merge(config, {
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
|
devServer: {
|
||||||
|
contentBase: path.join(__dirname, 'dist'),
|
||||||
|
compress: true,
|
||||||
|
port: 9000,
|
||||||
|
proxy: [{
|
||||||
|
context: ['/auth_token.js', '/ws'],
|
||||||
|
target: 'http://localhost:7681',
|
||||||
|
ws: true
|
||||||
|
}]
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
template: 'index.html',
|
template: 'index.html'
|
||||||
}),
|
})
|
||||||
],
|
]
|
||||||
serve: {
|
|
||||||
content: __dirname + '/dist',
|
|
||||||
add: (app, middleware, options) => {
|
|
||||||
var ttydProxy = proxy(
|
|
||||||
[
|
|
||||||
'/ws',
|
|
||||||
'/auth_token.js',
|
|
||||||
],
|
|
||||||
{
|
|
||||||
target: 'http://127.0.0.1:7681',
|
|
||||||
ws: true,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
app.use(convert(ttydProxy));
|
|
||||||
},
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,17 +4,23 @@ const config = require('./webpack.config.js');
|
|||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
|
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
|
||||||
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
||||||
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
|
const TerserPlugin = require('terser-webpack-plugin');
|
||||||
|
|
||||||
module.exports = merge(config, {
|
module.exports = merge(config, {
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
optimization: {
|
optimization: {
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new UglifyJsPlugin({
|
new TerserPlugin({
|
||||||
cache: true,
|
sourceMap: true
|
||||||
parallel: true,
|
}),
|
||||||
|
new OptimizeCSSAssetsPlugin({
|
||||||
|
cssProcessorOptions: {
|
||||||
|
map: {
|
||||||
|
inline: false,
|
||||||
|
annotation: true
|
||||||
|
}
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
new OptimizeCSSAssetsPlugin({}),
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|||||||
7918
html/yarn.lock
7918
html/yarn.lock
File diff suppressed because it is too large
Load Diff
4
src/index.html
vendored
4
src/index.html
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user