Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
admin-trade
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haojie
admin-trade
Commits
3ca7c228
Commit
3ca7c228
authored
Jun 09, 2023
by
haojie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
35b8f47d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
17 deletions
+68
-17
resources/js/utils/rollup.ts
+43
-0
vite.config.js
+25
-17
No files found.
resources/js/utils/rollup.ts
0 → 100644
View file @
3ca7c228
export
class
SplitVendorChunkCache
{
constructor
()
{
this
.
cache
=
new
Map
();
}
reset
()
{
this
.
cache
=
new
Map
();
}
}
export
function
staticImportedByEntry
(
id
,
getModuleInfo
,
cache
,
importStack
=
[]
)
{
if
(
cache
.
has
(
id
))
{
return
!!
cache
.
get
(
id
);
}
if
(
importStack
.
includes
(
id
))
{
cache
.
set
(
id
,
false
);
return
false
;
}
const
mod
=
getModuleInfo
(
id
);
if
(
!
mod
)
{
cache
.
set
(
id
,
false
);
return
false
;
}
if
(
mod
.
isEntry
)
{
cache
.
set
(
id
,
true
);
return
true
;
}
const
someImporterIs
=
mod
.
importers
.
some
((
importer
)
=>
staticImportedByEntry
(
importer
,
getModuleInfo
,
cache
,
importStack
.
concat
(
id
)
)
);
cache
.
set
(
id
,
someImporterIs
);
return
someImporterIs
;
}
vite.config.js
View file @
3ca7c228
...
@@ -3,11 +3,12 @@ import laravel from 'laravel-vite-plugin';
...
@@ -3,11 +3,12 @@ import laravel from 'laravel-vite-plugin';
import
React
from
'@vitejs/plugin-react'
;
import
React
from
'@vitejs/plugin-react'
;
import
viteCompression
from
'vite-plugin-compression'
;
import
viteCompression
from
'vite-plugin-compression'
;
import
svgr
from
'vite-plugin-svgr'
;
import
svgr
from
'vite-plugin-svgr'
;
// import {SplitVendorChunkCache, staticImportedByEntry} from './resources/js/utils/rollup';
// const cache = new SplitVendorChunkCache();
export
default
defineConfig
({
export
default
defineConfig
({
plugins
:
[
laravel
({
plugins
:
[
laravel
({
input
:
[
'resources/js/app.jsx'
],
refresh
:
false
,
input
:
[
'resources/js/app.jsx'
],
refresh
:
false
,
// 构建ssr
// 构建ssr
ssr
:
'resources/js/ssr.jsx'
,
ssr
:
'resources/js/ssr.jsx'
,
}),
React
(),
viteCompression
(),
svgr
()],
server
:
{
}),
React
(),
viteCompression
(),
svgr
()],
server
:
{
port
:
3008
,
host
:
'127.0.0.1'
,
proxy
:
{
port
:
3008
,
host
:
'127.0.0.1'
,
proxy
:
{
...
@@ -17,32 +18,39 @@ export default defineConfig({
...
@@ -17,32 +18,39 @@ export default defineConfig({
esbuildOptions
:
{
esbuildOptions
:
{
loader
:
{
'.tsx'
:
'jsx'
}
loader
:
{
'.tsx'
:
'jsx'
}
}
}
},
},
resolve
:
{
resolve
:
{
alias
:
{
alias
:
{
'@'
:
'/resources'
'@'
:
'/resources'
}
}
},
},
build
:
{
build
:
{
minify
:
'terser'
,
// 混淆器,terser构建后文件体积更小
minify
:
'terser'
,
// 混淆器,terser构建后文件体积更小
terserOptions
:
{
terserOptions
:
{
compress
:
{
compress
:
{
//生产环境时移除console
//生产环境时移除console
drop_console
:
true
,
drop_console
:
true
,
// drop_debugger: true,
// drop_debugger: true,
},
output
:
{
},
output
:
{
// 去掉注释内容
// 去掉注释内容
comments
:
false
,
comments
:
false
,
},
},
},
},
rollupOptions
:
{
rollupOptions
:
{
output
:
{
output
:
{
manualChunks
:
{
// manualChunks: {
// 拆分代码,这个就是分包,配置完后自动按需加载
// // 拆分代码,这个就是分包,配置完后自动按需加载
// react: ['react'],
// // react: ['react'],
// 'tdesign-react': ['tdesign-react'],
// // 'tdesign-react': ['tdesign-react'],
},
// },
// manualChunks(id, {getModuleInfo}) {
// const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
// const cssLangRE = new RegExp(cssLangs);
// const isCSSRequest = (request) => cssLangRE.test(request);
// // 分vendor包
// if (id.includes('node_modules') && !isCSSRequest(id) && staticImportedByEntry(id, getModuleInfo, cache.cache)) {
// return 'vendor';
// } else if (// 分manifest包,解决chunk碎片问题
// ((getModuleInfo(id).importers.length + getModuleInfo(id).dynamicImporters.length) > 1) && id.includes('src')) {
// return 'manifest_c';
// }
// }
},
},
},
},
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment