1 Star 1 Fork 1

sli97/eva-start-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webpack.config.js 2.93 KB
一键复制 编辑 原始数据 按行查看 历史
liangchaogui 提交于 2022-03-09 18:00 . 静态资源打包路径修改
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,
}),
],
},
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sli97/eva-start-demo.git
git@gitee.com:sli97/eva-start-demo.git
sli97
eva-start-demo
eva-start-demo
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385