fixed. 演练场静态打包问题

This commit is contained in:
q
2026-01-04 09:29:20 +08:00
parent d8f0dc4f8e
commit 8127cd0758
8 changed files with 195 additions and 21 deletions

View File

@@ -4,8 +4,10 @@ const path = require("path");
function resolve(dir) {
return path.join(__dirname, dir)
}
const CompressionPlugin = require('compression-webpack-plugin');
const FileManagerPlugin = require('filemanager-webpack-plugin')
const FileManagerPlugin = require('filemanager-webpack-plugin');
const MonacoEditorPlugin = require('monaco-editor-webpack-plugin');
module.exports = {
productionSourceMap: false, // 是否在构建生产包时生成sourceMap文件false将提高构建速度
@@ -43,7 +45,7 @@ module.exports = {
'@': resolve('src')
}
},
// Monaco Editor配置 - 使用国内CDN
// Monaco Editor配置 - 使用本地打包
module: {
rules: [
{
@@ -53,9 +55,18 @@ module.exports = {
]
},
plugins: [
new MonacoEditorPlugin({
languages: ['javascript', 'typescript', 'json'],
features: ['coreCommands', 'find', 'format', 'suggest', 'quickCommand'],
publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
// Worker 文件输出路径
filename: 'js/[name].worker.js'
}),
new CompressionPlugin({
test: /\.js$|\.html$|\.css/, // 匹配文件
threshold: 10240 // 对超过10k文件压缩
threshold: 10240, // 对超过10k文件压缩
// 排除 js 目录下的 worker 文件Monaco Editor 使用 vs/assets 下的)
exclude: /js\/.*\.worker\.js$/
}),
new FileManagerPlugin({ //初始化 filemanager-webpack-plugin 插件实例
events: {
@@ -70,7 +81,11 @@ module.exports = {
{ source: '../webroot/nfd-front/view/.gitignore', options: { force: true } },
],
copy: [
{ source: './nfd-front', destination: '../webroot/nfd-front' }
// 复制 Monaco Editor 的 vs 目录到 js/vs
{
source: './node_modules/monaco-editor/min/vs',
destination: './nfd-front/js/vs'
}
],
archive: [ //然后我们选择dist文件夹将之打包成dist.zip并放在根目录
{