mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-21 11:24:20 +01:00
* build(deps-dev): bump copy-webpack-plugin from 5.1.1 to 6.0.2 in /html Bumps [copy-webpack-plugin](https://github.com/webpack-contrib/copy-webpack-plugin) from 5.1.1 to 6.0.2. - [Release notes](https://github.com/webpack-contrib/copy-webpack-plugin/releases) - [Changelog](https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/CHANGELOG.md) - [Commits](https://github.com/webpack-contrib/copy-webpack-plugin/compare/v5.1.1...v6.0.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * html: update webpack config Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Shuanglei Tao <tsl0922@gmail.com>
107 lines
2.8 KiB
JavaScript
107 lines
2.8 KiB
JavaScript
const path = require('path');
|
|
const merge = require('webpack-merge');
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
|
|
const devMode = process.env.NODE_ENV !== 'production';
|
|
|
|
const baseConfig = {
|
|
context: path.resolve(__dirname, 'src'),
|
|
entry: {
|
|
app: './index.tsx'
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, 'dist'),
|
|
filename: devMode ? '[name].js' : '[name].[hash].js',
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ts$/,
|
|
enforce: 'pre',
|
|
use: 'tslint-loader',
|
|
},
|
|
{
|
|
test: /\.tsx?$/,
|
|
use: 'ts-loader',
|
|
exclude: /node_modules/
|
|
},
|
|
{
|
|
test: /\.s?[ac]ss$/,
|
|
use: [
|
|
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
|
|
'css-loader',
|
|
'sass-loader',
|
|
],
|
|
},
|
|
]
|
|
},
|
|
resolve: {
|
|
extensions: [ '.tsx', '.ts', '.js' ]
|
|
},
|
|
plugins: [
|
|
new CopyWebpackPlugin({
|
|
patterns:[
|
|
{ from: './favicon.png', to: '.' }
|
|
],
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: devMode ? '[name].css' : '[name].[hash].css',
|
|
chunkFilename: devMode ? '[id].css' : '[id].[hash].css',
|
|
}),
|
|
new HtmlWebpackPlugin({
|
|
inject: false,
|
|
minify: {
|
|
removeComments: true,
|
|
collapseWhitespace: true,
|
|
},
|
|
title: 'ttyd - Terminal',
|
|
template: './template.html'
|
|
})
|
|
],
|
|
performance : {
|
|
hints : false
|
|
},
|
|
};
|
|
|
|
const devConfig = {
|
|
mode: 'development',
|
|
devServer: {
|
|
contentBase: path.join(__dirname, 'dist'),
|
|
compress: true,
|
|
port: 9000,
|
|
proxy: [{
|
|
context: ['/token', '/ws'],
|
|
target: 'http://localhost:7681',
|
|
ws: true
|
|
}]
|
|
},
|
|
devtool: 'inline-source-map',
|
|
};
|
|
|
|
const prodConfig = {
|
|
mode: 'production',
|
|
optimization: {
|
|
minimizer: [
|
|
new TerserPlugin({
|
|
sourceMap: true
|
|
}),
|
|
new OptimizeCSSAssetsPlugin({
|
|
cssProcessorOptions: {
|
|
map: {
|
|
inline: false,
|
|
annotation: true
|
|
}
|
|
}
|
|
}),
|
|
]
|
|
},
|
|
devtool: 'source-map',
|
|
};
|
|
|
|
|
|
module.exports = merge(baseConfig, devMode ? devConfig : prodConfig);
|