Skip to content

Commit

Permalink
wip(uts): 支持小程序加密插件
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Jan 21, 2025
1 parent 444a2e3 commit b39d017
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
25 changes: 17 additions & 8 deletions packages/uni-mp-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
resolveSourceMapPath,
resolveUTSCompiler,
uniDecryptUniModulesPlugin,
uniEncryptUniModulesAssetsPlugin,
uniEncryptUniModulesPlugin,
uniHBuilderXConsolePlugin,
uniSourceMapPlugin,
uniUTSUVueJavaScriptPlugin,
Expand Down Expand Up @@ -66,14 +68,18 @@ export default (options: UniMiniProgramPluginOptions) => {
}),
]
: []),
() => {
return uniMainJsPlugin({
normalizeComponentName,
babelParserPlugins: ['typescript'],
})
},
uniManifestJsonPlugin(options),
uniPagesJsonPlugin(options),
...(process.env.UNI_COMPILE_TARGET === 'uni_modules'
? []
: [
() => {
return uniMainJsPlugin({
normalizeComponentName,
babelParserPlugins: ['typescript'],
})
},
uniManifestJsonPlugin(options),
uniPagesJsonPlugin(options),
]),
uniEntryPlugin(options),
uniViteInjectPlugin(
'uni:mp-inject',
Expand All @@ -92,6 +98,9 @@ export default (options: UniMiniProgramPluginOptions) => {
},
...(process.env.UNI_SUBPACKAGE ? [uniSubpackagePlugin(options)] : []),
...(process.env.UNI_MP_PLUGIN ? [uniMiniProgramPluginPlugin(options)] : []),
...(process.env.UNI_COMPILE_TARGET === 'uni_modules'
? [uniEncryptUniModulesAssetsPlugin(), uniEncryptUniModulesPlugin()]
: []),
uniSourceMapPlugin({
sourceMapDir,
relativeSourceMapDir: normalizePath(
Expand Down
20 changes: 13 additions & 7 deletions packages/uni-mp-vite/src/plugin/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,20 @@ export function createBuildOptions(
sourcemap: isEnableConsole() && enableSourceMap(),
// target: ['chrome53'], // 由小程序自己启用 es6 编译
emptyOutDir: false, // 不清空输出目录,否则会影响自定义的一些文件输出,比如wxml
lib: {
// 必须使用 lib 模式,否则会生成 preload 等代码
fileName: 'app.js',
entry: resolveMainPathOnce(inputDir),
formats: ['cjs'],
},
lib:
process.env.UNI_COMPILE_TARGET === 'uni_modules'
? false
: {
// 必须使用 lib 模式,否则会生成 preload 等代码
fileName: 'app.js',
entry: resolveMainPathOnce(inputDir),
formats: ['cjs'],
},
rollupOptions: {
input: parseRollupInput(inputDir, platform),
input:
process.env.UNI_COMPILE_TARGET === 'uni_modules'
? {}
: parseRollupInput(inputDir, platform),
output: {
sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => {
const result = sourcemapPathTransform(
Expand Down

0 comments on commit b39d017

Please sign in to comment.