Skip to content

Commit

Permalink
feat: add build:visualizer script
Browse files Browse the repository at this point in the history
  • Loading branch information
ckvv committed Dec 24, 2021
1 parent 5a98913 commit 6caa85d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"build:visualizer": "visualizer=true vite build",
"serve": "vite preview",
"lint": "eslint --fix ./",
"prepare": "husky install",
Expand Down
24 changes: 13 additions & 11 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ import WindiCSS from 'vite-plugin-windicss';
import { visualizer } from 'rollup-plugin-visualizer';
import PACKAGE from './package.json';

const visualizerPlugin = visualizer({
name: `${PACKAGE.name}-report`,
template: 'treemap',
filename: 'report/report.html',
gzipSize: true,
});
visualizerPlugin.outputOptions = () => {
console.info(`\nReport: file://${__dirname}/report/report.html\n`);
};

const plugins = [WindiCSS(), vue(), visualizerPlugin];
const plugins = [WindiCSS(), vue()];

if (process.env.visualizer) {
const visualizerPlugin = visualizer({
name: `${PACKAGE.name}-report`,
template: 'treemap',
filename: 'report/index.html',
gzipSize: true,
});
visualizerPlugin.outputOptions = () => {
console.info(`\nReport: file://${path.resolve()}/report/index.html\n`);
};
plugins.push(visualizerPlugin);
}
// https://vitejs.dev/config/
export default defineConfig({
server: {
Expand Down

0 comments on commit 6caa85d

Please sign in to comment.