diff options
Diffstat (limited to 'html/webpack.config.js')
-rw-r--r-- | html/webpack.config.js | 81 |
1 files changed, 38 insertions, 43 deletions
diff --git a/html/webpack.config.js b/html/webpack.config.js index 48e74c3..18bfcf3 100644 --- a/html/webpack.config.js +++ b/html/webpack.config.js @@ -1,8 +1,9 @@ const path = require('path'); const { merge } = require('webpack-merge'); +const ESLintPlugin = require('eslint-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); -const MiniCssExtractPlugin = require("mini-css-extract-plugin"); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); @@ -11,7 +12,7 @@ const devMode = process.env.NODE_ENV !== 'production'; const baseConfig = { context: path.resolve(__dirname, 'src'), entry: { - app: './index.tsx' + app: './index.tsx', }, output: { path: path.resolve(__dirname, 'dist'), @@ -20,42 +21,26 @@ const baseConfig = { module: { rules: [ { - test: /\.ts$/, - enforce: 'pre', - use: 'tslint-loader', - }, - { test: /\.tsx?$/, use: 'ts-loader', - exclude: /node_modules/ + exclude: /node_modules/, }, { test: /\.s?[ac]ss$/, - use: [ - devMode ? 'style-loader' : MiniCssExtractPlugin.loader, - 'css-loader', - 'sass-loader', - ], - }, - { - test: /xterm-addon-image-worker/, - type: 'asset/inline', - generator: { - dataUrl: content => { - return content.toString(); - } - } + use: [devMode ? 'style-loader' : MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'], }, - ] + ], }, resolve: { - extensions: [ '.tsx', '.ts', '.js' ] + extensions: ['.tsx', '.ts', '.js'], }, plugins: [ + new ESLintPlugin({ + context: path.resolve(__dirname, '.'), + extensions: ['js', 'jsx', 'ts', 'tsx'], + }), new CopyWebpackPlugin({ - patterns:[ - { from: './favicon.png', to: '.' } - ], + patterns: [{ from: './favicon.png', to: '.' }], }), new MiniCssExtractPlugin({ filename: devMode ? '[name].css' : '[name].[contenthash].css', @@ -68,25 +53,39 @@ const baseConfig = { collapseWhitespace: true, }, title: 'ttyd - Terminal', - template: './template.html' - }) + template: './template.html', + }), ], - performance : { - hints : false + performance: { + hints: false, }, }; -const devConfig = { +const devConfig = { mode: 'development', devServer: { - contentBase: path.join(__dirname, 'dist'), + static: path.join(__dirname, 'dist'), compress: true, port: 9000, - proxy: [{ - context: ['/token', '/ws'], - target: 'http://localhost:7681', - ws: true - }] + client: { + overlay: { + errors: true, + warnings: false, + }, + }, + proxy: [ + { + context: ['/token', '/ws'], + target: 'http://localhost:7681', + ws: true, + }, + ], + webSocketServer: { + type: 'sockjs', + options: { + path: '/sockjs-node', + }, + }, }, devtool: 'inline-source-map', }; @@ -94,13 +93,9 @@ const devConfig = { const prodConfig = { mode: 'production', optimization: { - minimizer: [ - new TerserPlugin(), - new CssMinimizerPlugin(), - ] + minimizer: [new TerserPlugin(), new CssMinimizerPlugin()], }, devtool: 'source-map', }; - module.exports = merge(baseConfig, devMode ? devConfig : prodConfig); |