代码拉取完成,页面将自动刷新
const path = require('path');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { ESBuildMinifyPlugin } = require('esbuild-loader');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
/*
* SplitChunksPlugin is enabled by default and replaced
* deprecated CommonsChunkPlugin. It automatically identifies modules which
* should be splitted of chunk by heuristics using module duplication count and
* module category (i. e. node_modules). And splits the chunks…
*
* It is safe to remove "splitChunks" from the generated configuration
* and was added as an educational example.
*
* https://webpack.js.org/plugins/split-chunks-plugin/
*
*/
/*
* We've enabled TerserPlugin for you! This minifies your app
* in order to load faster and run less javascript.
*
* https://github.com/webpack-contrib/terser-webpack-plugin
*
*/
const target = path.resolve(__dirname, './docs');
module.exports = {
mode: 'development',
entry: './src/index.ts',
devtool: 'inline-source-map',
output: {
path: target,
filename: 'main.js',
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
loader: 'esbuild-loader',
options: {
loader: 'tsx',
target: 'es2015',
},
include: [path.resolve(__dirname, 'src')],
exclude: [/node_modules/],
},
{
test: /.css$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
{
loader: 'esbuild-loader',
options: {
loader: 'css',
minify: true,
},
},
],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
fallback: { path: require.resolve('path-browserify') },
},
devServer: {
port: 9000,
compress: true,
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, './index.html'),
title: 'cramped room of death',
}),
new webpack.ProgressPlugin(),
new CleanWebpackPlugin(),
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, './static'),
to: path.join(target, 'static'),
ignore: ['.*'],
},
]),
],
optimization: {
minimizer: [
new ESBuildMinifyPlugin({
css: true,
}),
],
},
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。