-
Notifications
You must be signed in to change notification settings - Fork 0
[공통] visualize 정상화 및 css 옵션 추가 #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@naverpay/pite": minor | ||
| --- | ||
|
|
||
| [공통] visualize 정상화 및 css 옵션 추가 | ||
|
|
||
| PR: [[공통] visualize 정상화 및 css 옵션 추가](https://github.com/NaverPayDev/pite/pull/68) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import defaultBrowserslist from '@naverpay/browserslist-config' | |
| import babel from '@rollup/plugin-babel' | ||
| import browserslistToEsbuild from 'browserslist-to-esbuild' | ||
| import preserveDirectives from 'rollup-plugin-preserve-directives' | ||
| import visualizer from 'rollup-plugin-visualizer' | ||
| import {PluginVisualizerOptions, visualizer} from 'rollup-plugin-visualizer' | ||
| import {BuildOptions, defineConfig, Plugin} from 'vite' | ||
|
|
||
| import {getBrowserslistConfig} from './browserslist' | ||
|
|
@@ -17,11 +17,11 @@ export interface ViteConfigProps { | |
| cwd?: string | ||
| entry: string | string[] | Record<string, string> | ||
| outputs?: {format: 'es' | 'cjs'; dist: string}[] | ||
| cssFileName?: string | ||
| visualize?: boolean | ||
| visualize?: boolean | PluginVisualizerOptions | ||
| allowedPolyfills?: string[] | ||
| ignoredPolyfills?: string[] | ||
| options?: BuildOptions | ||
| css?: false | {filename: string; extract?: boolean; minify?: boolean; modules?: boolean; scss?: boolean} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| export function createViteConfig({ | ||
|
|
@@ -31,11 +31,11 @@ export function createViteConfig({ | |
| {format: 'es', dist: 'dist/esm'}, | ||
| {format: 'cjs', dist: 'dist/cjs'}, | ||
| ], | ||
| cssFileName = 'style.css', | ||
| visualize = false, | ||
| allowedPolyfills = [], | ||
| ignoredPolyfills = [], | ||
| options, | ||
| css: cssOptions = false, | ||
| }: ViteConfigProps) { | ||
| const browserslistConfig = getBrowserslistConfig(cwd) | ||
| const externalDeps = getExternalDependencies(cwd) | ||
|
|
@@ -65,9 +65,9 @@ export function createViteConfig({ | |
| const build: BuildOptions = { | ||
| target: browserslistToEsbuild(browserslist), | ||
| lib: { | ||
| cssFileName: cssFileName.replace('.css', ''), | ||
| formats, | ||
| entry: getViteEntry(entry), | ||
| ...(cssOptions ? {cssFileName: cssOptions.filename.replace('.css', '')} : {}), | ||
| ...inputLib, | ||
| }, | ||
| rollupOptions: { | ||
|
|
@@ -90,16 +90,6 @@ export function createViteConfig({ | |
|
|
||
| return `${chunkInfo.name}${extension}` | ||
| }, | ||
| assetFileNames: (assetInfo) => { | ||
| if (!assetInfo.names) { | ||
| return '' | ||
| } | ||
| if (assetInfo.names.length > 0 && assetInfo.names[0] === 'style.css') { | ||
| return cssFileName | ||
| } | ||
|
|
||
| return assetInfo.names[0] | ||
| }, | ||
| } | ||
| }), | ||
| plugins: [ | ||
|
|
@@ -126,16 +116,37 @@ export function createViteConfig({ | |
| exclude: /node_modules/, | ||
| }), | ||
| ...inputRollupPlugin, | ||
| ...(visualize ? [visualizer()] : []), | ||
| ...(visualize ? [visualizer(typeof visualize === 'object' ? visualize : {})] : []), | ||
| preserveDirectives(), | ||
| publint({cwd}), | ||
| ], | ||
| ...inputRollupOptions, | ||
| }, | ||
| ...(cssOptions | ||
| ? { | ||
| cssCodeSplit: cssOptions.extract || false, | ||
| cssMinify: cssOptions.minify || false, | ||
| } | ||
| : {}), | ||
| ...restOptions, | ||
| } | ||
|
|
||
| const plugins = [vitePluginTsup({formats, entry, outDir: {esm: esmDir, cjs: cjsDir}})] | ||
|
|
||
| return defineConfig({build, plugins}) | ||
| return defineConfig({ | ||
| build, | ||
| plugins, | ||
| ...(cssOptions | ||
| ? { | ||
| css: { | ||
| modules: cssOptions.modules | ||
| ? {localsConvention: 'camelCase', generateScopedName: '[name]__[local]___[hash:base64:5]'} | ||
| : false, | ||
| preprocessorOptions: cssOptions.scss | ||
| ? {scss: {additionalData: `@use "sass:math"; @use "sass:color";`}} | ||
| : undefined, | ||
| }, | ||
| } | ||
| : {}), | ||
| }) | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
visualize 관련 옵션 받을 수 있게 수정