My data file, named data.ts
, contains a large dataset:
export data = [
... // huge data
]
The lib.ts
file only utilizes a portion of the data
:
import { data } from './data.ts';
const fitteredData = data.splice(0,2) // only use some of them
export { fitteredData };
I am using fitteredData
in my Vue component:
<script setup lang="ts">
import { fitteredData } from "./lib";
</script>
<template>
<div>{{ fitteredData }}</div>
</template>
When I run pnpm build
, I noticed that all the data from data.ts
is included in the final built file. How can I ensure that the final file only contains the fitteredData
to reduce its size?
Is there a way to optimize the final built files so that they only include the fitteredData
and nothing else?