|
@@ -3,7 +3,6 @@ import HtmlWebpackPlugin from 'html-webpack-plugin'
|
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
|
import CopyWebpackPlugin from 'copy-webpack-plugin'
|
|
import CopyWebpackPlugin from 'copy-webpack-plugin'
|
|
import TerserPlugin from 'terser-webpack-plugin'
|
|
import TerserPlugin from 'terser-webpack-plugin'
|
|
-import filetool from 'huan-file-tool'
|
|
|
|
import { fileURLToPath } from 'url'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
@@ -25,85 +24,6 @@ const html_minify = {
|
|
minifyURLs: true
|
|
minifyURLs: true
|
|
}
|
|
}
|
|
|
|
|
|
-const HTMMLPlugin = []
|
|
|
|
-
|
|
|
|
-const { localPathResult: AllHTMLLocalFile4xx } = filetool.filewaalk.getAllFilePaths(
|
|
|
|
- path.resolve(__dirname, 'src/html/error/4xx')
|
|
|
|
-)
|
|
|
|
-AllHTMLLocalFile4xx.forEach((filePath) => {
|
|
|
|
- if (!filePath.endsWith('.html')) {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (filePath.includes('signal')) {
|
|
|
|
- HTMMLPlugin.push(
|
|
|
|
- new HtmlWebpackPlugin({
|
|
|
|
- inject: 'body',
|
|
|
|
- template: path.resolve(__dirname, 'src/html/error/4xx', filePath), //指定模板文件
|
|
|
|
- filename: path.join('error/4xx', filePath),
|
|
|
|
- chunks: ['signal'],
|
|
|
|
- publicPath: '../../'
|
|
|
|
- })
|
|
|
|
- )
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (filePath.includes('404')) {
|
|
|
|
- HTMMLPlugin.push(
|
|
|
|
- new HtmlWebpackPlugin({
|
|
|
|
- inject: 'body',
|
|
|
|
- template: path.resolve(__dirname, 'src/html/error/4xx', filePath), //指定模板文件
|
|
|
|
- filename: path.join('error/4xx', filePath),
|
|
|
|
- chunks: ['common', 'err404'],
|
|
|
|
- publicPath: '../../'
|
|
|
|
- })
|
|
|
|
- )
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- HTMMLPlugin.push(
|
|
|
|
- new HtmlWebpackPlugin({
|
|
|
|
- inject: 'body',
|
|
|
|
- template: path.resolve(__dirname, 'src/html/error/4xx', filePath), //指定模板文件
|
|
|
|
- filename: path.join('error/4xx', filePath),
|
|
|
|
- chunks: ['common', 'err4xx'],
|
|
|
|
- publicPath: '../../'
|
|
|
|
- })
|
|
|
|
- )
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
-const { localPathResult: AllHTMLLocalFile5xx } = filetool.filewaalk.getAllFilePaths(
|
|
|
|
- path.resolve(__dirname, 'src/html/error/5xx')
|
|
|
|
-)
|
|
|
|
-AllHTMLLocalFile5xx.forEach((filePath) => {
|
|
|
|
- if (!filePath.endsWith('.html')) {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (filePath.includes('signal')) {
|
|
|
|
- HTMMLPlugin.push(
|
|
|
|
- new HtmlWebpackPlugin({
|
|
|
|
- inject: 'body',
|
|
|
|
- template: path.resolve(__dirname, 'src/html/error/5xx', filePath), //指定模板文件
|
|
|
|
- filename: path.join('error/5xx', filePath),
|
|
|
|
- chunks: ['signal'],
|
|
|
|
- publicPath: '../../'
|
|
|
|
- })
|
|
|
|
- )
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- HTMMLPlugin.push(
|
|
|
|
- new HtmlWebpackPlugin({
|
|
|
|
- inject: 'body',
|
|
|
|
- template: path.resolve(__dirname, 'src/html/error/5xx', filePath), //指定模板文件
|
|
|
|
- filename: path.join('error/5xx', filePath),
|
|
|
|
- chunks: ['common', 'err5xx'],
|
|
|
|
- publicPath: '../../'
|
|
|
|
- })
|
|
|
|
- )
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
const config = {
|
|
const config = {
|
|
mode: mode,
|
|
mode: mode,
|
|
|
|
|
|
@@ -118,13 +38,9 @@ const config = {
|
|
entry: {
|
|
entry: {
|
|
common: path.resolve(__dirname, 'src/common.js'),
|
|
common: path.resolve(__dirname, 'src/common.js'),
|
|
index: path.resolve(__dirname, 'src/index.js'),
|
|
index: path.resolve(__dirname, 'src/index.js'),
|
|
- signal: path.resolve(__dirname, 'src/signal.js'),
|
|
|
|
- new: path.resolve(__dirname, 'src/new.js'),
|
|
|
|
- license: path.resolve(__dirname, 'src/license.js'),
|
|
|
|
- mitorg: path.resolve(__dirname, 'src/mitorg.js'),
|
|
|
|
- err4xx: path.resolve(__dirname, 'src/4xx.js'),
|
|
|
|
- err404: path.resolve(__dirname, 'src/404.js'),
|
|
|
|
- err5xx: path.resolve(__dirname, 'src/5xx.js')
|
|
|
|
|
|
+ leave: path.resolve(__dirname, 'src/leave.js'),
|
|
|
|
+ sponsors: path.resolve(__dirname, 'src/sponsors.js'),
|
|
|
|
+ contributors: path.resolve(__dirname, "src/contributors.js")
|
|
},
|
|
},
|
|
|
|
|
|
output: {
|
|
output: {
|
|
@@ -178,7 +94,7 @@ const config = {
|
|
limit: 8192, // 8KB 以下的文件将被转换为 Data URL
|
|
limit: 8192, // 8KB 以下的文件将被转换为 Data URL
|
|
fallback: 'file-loader',
|
|
fallback: 'file-loader',
|
|
outputPath: 'images', // 类似于 file-loader 的配置
|
|
outputPath: 'images', // 类似于 file-loader 的配置
|
|
- name: '[name].[fullhash].[ext]'
|
|
|
|
|
|
+ name: '[name].[hash].[ext]'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
]
|
|
@@ -192,7 +108,7 @@ const config = {
|
|
limit: 8192, // 8KB 以下的文件将被转换为 Data URL
|
|
limit: 8192, // 8KB 以下的文件将被转换为 Data URL
|
|
fallback: 'file-loader',
|
|
fallback: 'file-loader',
|
|
outputPath: 'videos', // 类似于 file-loader 的配置
|
|
outputPath: 'videos', // 类似于 file-loader 的配置
|
|
- name: '[name].[fullhash].[ext]'
|
|
|
|
|
|
+ name: '[name].[hash].[ext]'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
]
|
|
@@ -206,7 +122,7 @@ const config = {
|
|
limit: 8192, // 8KB 以下的文件将被转换为 Data URL
|
|
limit: 8192, // 8KB 以下的文件将被转换为 Data URL
|
|
fallback: 'file-loader',
|
|
fallback: 'file-loader',
|
|
outputPath: 'fonts', // 类似于 file-loader 的配置
|
|
outputPath: 'fonts', // 类似于 file-loader 的配置
|
|
- name: '[name].[fullhash].[ext]'
|
|
|
|
|
|
+ name: '[name].[hash].[ext]'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
]
|
|
@@ -222,15 +138,12 @@ const config = {
|
|
new CopyWebpackPlugin({
|
|
new CopyWebpackPlugin({
|
|
patterns: [
|
|
patterns: [
|
|
{ from: 'public', to: './' },
|
|
{ from: 'public', to: './' },
|
|
- { from: './config.json', to: './SH_CONFIG.json' },
|
|
|
|
- { from: './LICENSE', to: './' },
|
|
|
|
- { from: './LICENSE_CN', to: './' }
|
|
|
|
|
|
+ { from: './config.json', to: './CONFIG.json' },
|
|
]
|
|
]
|
|
}),
|
|
}),
|
|
- ...HTMMLPlugin,
|
|
|
|
new HtmlWebpackPlugin({
|
|
new HtmlWebpackPlugin({
|
|
inject: 'body',
|
|
inject: 'body',
|
|
- template: path.resolve(__dirname, 'src', 'html', 'index.html'), //指定模板文件
|
|
|
|
|
|
+ template: path.resolve(__dirname, 'src/html/index.html'), //指定模板文件
|
|
filename: 'index.html',
|
|
filename: 'index.html',
|
|
chunks: ['common', 'index'],
|
|
chunks: ['common', 'index'],
|
|
minify: html_minify,
|
|
minify: html_minify,
|
|
@@ -238,54 +151,30 @@ const config = {
|
|
}),
|
|
}),
|
|
new HtmlWebpackPlugin({
|
|
new HtmlWebpackPlugin({
|
|
inject: 'body',
|
|
inject: 'body',
|
|
- template: path.resolve(__dirname, 'src', 'html', 'LICENSE_US.html'), //指定模板文件
|
|
|
|
- filename: 'LICENSE_US.html',
|
|
|
|
- chunks: ['common', 'license'],
|
|
|
|
- minify: html_minify,
|
|
|
|
- publicPath: './'
|
|
|
|
- }),
|
|
|
|
- new HtmlWebpackPlugin({
|
|
|
|
- inject: 'body',
|
|
|
|
- template: path.resolve(__dirname, 'src', 'html', 'LICENSE_CN.html'), //指定模板文件
|
|
|
|
- filename: 'LICENSE_CN.html',
|
|
|
|
- chunks: ['common', 'license'],
|
|
|
|
- minify: html_minify,
|
|
|
|
- publicPath: './'
|
|
|
|
- }),
|
|
|
|
- new HtmlWebpackPlugin({
|
|
|
|
- inject: 'body',
|
|
|
|
- template: path.resolve(__dirname, 'src', 'html', 'mitorg.html'), //指定模板文件
|
|
|
|
- filename: 'mitorg.html',
|
|
|
|
- chunks: ['common', 'mitorg'],
|
|
|
|
- minify: html_minify,
|
|
|
|
- publicPath: './'
|
|
|
|
- }),
|
|
|
|
- new HtmlWebpackPlugin({
|
|
|
|
- inject: 'body',
|
|
|
|
- template: path.resolve(__dirname, 'src', 'html', 'index.new.signal.html'), //指定模板文件
|
|
|
|
- filename: 'index.new.signal.html',
|
|
|
|
- chunks: ['common', 'new', 'signal'], // 此signal要设置common
|
|
|
|
|
|
+ template: path.resolve(__dirname, 'src/html/leave.html'), //指定模板文件
|
|
|
|
+ filename: 'leave.html',
|
|
|
|
+ chunks: ['common', 'leave'],
|
|
minify: html_minify,
|
|
minify: html_minify,
|
|
publicPath: './'
|
|
publicPath: './'
|
|
}),
|
|
}),
|
|
new HtmlWebpackPlugin({
|
|
new HtmlWebpackPlugin({
|
|
inject: 'body',
|
|
inject: 'body',
|
|
- template: path.resolve(__dirname, 'src', 'html', 'index.new.html'), //指定模板文件
|
|
|
|
- filename: 'index.new.html',
|
|
|
|
- chunks: ['common', 'new'],
|
|
|
|
|
|
+ template: path.resolve(__dirname, 'src/html/sponsors.html'), //指定模板文件
|
|
|
|
+ filename: 'sponsors.html',
|
|
|
|
+ chunks: ['common', 'sponsors'],
|
|
minify: html_minify,
|
|
minify: html_minify,
|
|
publicPath: './'
|
|
publicPath: './'
|
|
}),
|
|
}),
|
|
new HtmlWebpackPlugin({
|
|
new HtmlWebpackPlugin({
|
|
inject: 'body',
|
|
inject: 'body',
|
|
- template: path.resolve(__dirname, 'src/html/error/4xx/404.signal.html'), //指定模板文件
|
|
|
|
- filename: '404.html',
|
|
|
|
- chunks: ['common', 'signal'], // 此signal要设置common
|
|
|
|
|
|
+ template: path.resolve(__dirname, 'src/html/contributors.html'), //指定模板文件
|
|
|
|
+ filename: 'contributors.html',
|
|
|
|
+ chunks: ['common', 'contributors'],
|
|
minify: html_minify,
|
|
minify: html_minify,
|
|
publicPath: './'
|
|
publicPath: './'
|
|
}),
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
new MiniCssExtractPlugin({
|
|
- filename: 'style/[name].[hash].bundle.css',
|
|
|
|
|
|
+ filename: 'style/[name].[fullhash].bundle.css',
|
|
chunkFilename: 'css/[id].bundle.css'
|
|
chunkFilename: 'css/[id].bundle.css'
|
|
})
|
|
})
|
|
],
|
|
],
|