html: add .editorconfig

This commit is contained in:
Shuanglei Tao
2018-05-02 23:49:18 +08:00
parent 68b58829cd
commit b08fee3392
7 changed files with 112 additions and 101 deletions

11
html/.editorconfig Normal file
View File

@@ -0,0 +1,11 @@
root = true
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

View File

@@ -9,4 +9,4 @@ install [Yarn](https://yarnpkg.com), and run: `yarn install`.
## Publish ## Publish
Run `yarn run build`, this will compile the inlined html to `../src/index.html`. Run `yarn run build`, this will compile the inlined html to `../src/index.html`.

View File

@@ -1,9 +1,9 @@
const gulp = require('gulp'), const gulp = require('gulp'),
clean = require('gulp-clean'), clean = require('gulp-clean'),
inlinesource = require('gulp-inline-source'); inlinesource = require('gulp-inline-source');
gulp.task('clean', function () { gulp.task('clean', function () {
return gulp.src('dist', {read: false}) return gulp.src('dist', {read: false})
.pipe(clean()); .pipe(clean());
}); });

View File

@@ -1,46 +1,46 @@
{ {
"name": "ttyd", "name": "ttyd",
"version": "1.1.0", "version": "1.1.0",
"description": "Share your terminal over the web", "description": "Share your terminal over the web",
"main": "js/app.js", "main": "js/app.js",
"repository": { "repository": {
"url": "git@github.com:tsl0922/ttyd.git", "url": "git@github.com:tsl0922/ttyd.git",
"type": "git" "type": "git"
}, },
"author": "Shuanglei Tao <tsl0922@gmail.com>", "author": "Shuanglei Tao <tsl0922@gmail.com>",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build": "webpack --config webpack.prod.js && gulp", "build": "webpack --config webpack.prod.js && gulp",
"clean": "gulp clean", "clean": "gulp clean",
"start": "webpack-serve webpack.dev.js" "start": "webpack-serve webpack.dev.js"
}, },
"dependencies": { "dependencies": {
"bulma": "^0.6.1", "bulma": "^0.6.1",
"core-js": "^2.5.3", "core-js": "^2.5.3",
"fast-text-encoding": "^1.0.0", "fast-text-encoding": "^1.0.0",
"xterm": "^3.2.0", "xterm": "^3.2.0",
"zmodem.js": "^0.1.5" "zmodem.js": "^0.1.5"
}, },
"devDependencies": { "devDependencies": {
"babel-core": "^6.26.3", "babel-core": "^6.26.3",
"babel-loader": "^7.1.4", "babel-loader": "^7.1.4",
"babel-preset-env": "^1.6.1", "babel-preset-env": "^1.6.1",
"copy-webpack-plugin": "^4.5.1", "copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.8", "css-loader": "^0.28.8",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-clean": "^0.4.0", "gulp-clean": "^0.4.0",
"gulp-inline-source": "^3.1.0", "gulp-inline-source": "^3.1.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", "http-proxy-middleware": "^0.18.0",
"koa-connect": "^2.0.1", "koa-connect": "^2.0.1",
"mini-css-extract-plugin": "^0.4.0", "mini-css-extract-plugin": "^0.4.0",
"node-sass": "^4.7.2", "node-sass": "^4.7.2",
"sass-loader": "^6.0.6", "sass-loader": "^6.0.6",
"style-loader": "^0.19.1", "style-loader": "^0.19.1",
"webpack": "^4.6.0", "webpack": "^4.6.0",
"webpack-cli": "^2.1.2", "webpack-cli": "^2.1.2",
"webpack-merge": "^4.1.2", "webpack-merge": "^4.1.2",
"webpack-serve": "^0.3.2" "webpack-serve": "^0.3.2"
} }
} }

View File

@@ -9,34 +9,34 @@ module.exports = {
filename: devMode ? '[name].js' : '[name].[hash].js' filename: devMode ? '[name].js' : '[name].[hash].js'
}, },
module: { module: {
rules: [ rules: [
{ {
test: /\.js$/, test: /\.js$/,
exclude: /node_modules\/(?!zmodem.js\/)/, exclude: /node_modules\/(?!zmodem.js\/)/,
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
presets: ['env'] presets: ['env']
}
}
},
{
test: /\.s?[ac]ss$/,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
]
} }
} ]
},
{
test: /\.s?[ac]ss$/,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
]
}
]
}, },
plugins: [ plugins: [
new CopyWebpackPlugin([ new CopyWebpackPlugin([
{from: 'favicon.png', to: '.' } {from: 'favicon.png', to: '.' }
], {}), ], {}),
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: devMode ? '[name].css' : '[name].[hash].css', filename: devMode ? '[name].css' : '[name].[hash].css',
chunkFilename: devMode ? '[id].css' : '[id].[hash].css', chunkFilename: devMode ? '[id].css' : '[id].[hash].css',
}) })
] ]
} }

View File

@@ -6,27 +6,27 @@ 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, {
devtool: 'source-map', devtool: 'source-map',
mode: 'development', mode: 'development',
plugins: [ plugins: [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: 'index.html' template: 'index.html'
}) })
], ],
serve: { serve: {
content: __dirname + '/dist', content: __dirname + '/dist',
add: (app, middleware, options) => { add: (app, middleware, options) => {
var ttydProxy = proxy( var ttydProxy = proxy(
[ [
'/ws', '/ws',
'/auth_token.js' '/auth_token.js',
], ],
{ {
target: 'http://127.0.0.1:7681', target: 'http://127.0.0.1:7681',
ws: true ws: true,
} }
); );
app.use(convert(ttydProxy)); app.use(convert(ttydProxy));
} }
} }
}); });

View File

@@ -5,12 +5,12 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin'); const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
module.exports = merge(config, { module.exports = merge(config, {
mode: 'production', mode: 'production',
plugins: [ plugins: [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
inlineSource: '.(js|css)$', inlineSource: '.(js|css)$',
template: 'index.html' template: 'index.html'
}), }),
new HtmlWebpackInlineSourcePlugin() new HtmlWebpackInlineSourcePlugin()
] ]
}); });