@@ -9,6 +9,9 @@ import { lessLoader } from 'esbuild-plugin-less';
99import fs from 'fs-extra' ;
1010import { getZeroMQPreBuildsFoldersToKeep , getBundleConfiguration , bundleConfiguration } from '../webpack/common' ;
1111import ImportGlobPlugin from 'esbuild-plugin-import-glob' ;
12+ import postcss from 'postcss' ;
13+ import tailwindcss from '@tailwindcss/postcss' ;
14+ import autoprefixer from 'autoprefixer' ;
1215const plugin = require ( 'node-stdlib-browser/helpers/esbuild/plugin' ) ;
1316const stdLibBrowser = require ( 'node-stdlib-browser' ) ;
1417
@@ -45,6 +48,8 @@ const commonExternals = [
4548 'vscode' ,
4649 'commonjs' ,
4750 'node:crypto' ,
51+ 'node:fs/promises' ,
52+ 'node:path' ,
4853 'vscode-jsonrpc' , // Used by a few modules, might as well pull this out, instead of duplicating it in separate bundles.
4954 // Ignore telemetry specific packages that are not required.
5055 'applicationinsights-native-metrics' ,
@@ -86,7 +91,11 @@ const loader: { [ext: string]: Loader } = {
8691
8792// https://github.com/evanw/esbuild/issues/20#issuecomment-802269745
8893// https://github.com/hyrious/esbuild-plugin-style
89- function style ( { minify = true , charset = 'utf8' } : StylePluginOptions = { } ) : Plugin {
94+ function style ( {
95+ minify = true ,
96+ charset = 'utf8' ,
97+ enableTailwind = false
98+ } : StylePluginOptions & { enableTailwind ?: boolean } = { } ) : Plugin {
9099 return {
91100 name : 'style' ,
92101 setup ( { onResolve, onLoad } ) {
@@ -132,6 +141,32 @@ function style({ minify = true, charset = 'utf8' }: StylePluginOptions = {}): Pl
132141 } ) ) ;
133142
134143 onLoad ( { filter : / .* / , namespace : 'style-content' } , async ( args ) => {
144+ // Process with PostCSS/Tailwind if enabled and file exists
145+ if ( enableTailwind && args . path . includes ( 'tailwind.css' ) && fs . existsSync ( args . path ) ) {
146+ try {
147+ const cssContent = await fs . readFile ( args . path , 'utf8' ) ;
148+ const result = await postcss ( [ tailwindcss , autoprefixer ] ) . process ( cssContent , {
149+ from : args . path ,
150+ to : args . path
151+ } ) ;
152+
153+ const options = { ...opt , stdin : { contents : result . css , loader : 'css' } } ;
154+ options . loader = options . loader || { } ;
155+ // Add the same loaders we add for other places
156+ Object . keys ( loader ) . forEach ( ( key ) => {
157+ if ( options . loader && ! options . loader [ key ] ) {
158+ options . loader [ key ] = loader [ key ] ;
159+ }
160+ } ) ;
161+ const { errors, warnings, outputFiles } = await esbuild . build ( options ) ;
162+ return { errors, warnings, contents : outputFiles ! [ 0 ] . text , loader : 'text' } ;
163+ } catch ( error ) {
164+ console . error ( `PostCSS processing failed for ${ args . path } :` , error ) ;
165+ throw error ;
166+ }
167+ }
168+
169+ // Default behavior for other CSS files
135170 const options = { entryPoints : [ args . path ] , ...opt } ;
136171 options . loader = options . loader || { } ;
137172 // Add the same loaders we add for other places
@@ -140,7 +175,9 @@ function style({ minify = true, charset = 'utf8' }: StylePluginOptions = {}): Pl
140175 options . loader [ key ] = loader [ key ] ;
141176 }
142177 } ) ;
178+
143179 const { errors, warnings, outputFiles } = await esbuild . build ( options ) ;
180+
144181 return { errors, warnings, contents : outputFiles ! [ 0 ] . text , loader : 'text' } ;
145182 } ) ;
146183 }
@@ -158,7 +195,9 @@ function createConfig(
158195 const plugins : Plugin [ ] = [ ] ;
159196 let define : SameShape < BuildOptions , BuildOptions > [ 'define' ] = undefined ;
160197 if ( target === 'web' ) {
161- plugins . push ( style ( ) ) ;
198+ // Enable Tailwind processing for dataframe renderer
199+ const enableTailwind = source . includes ( path . join ( 'dataframe-renderer' , 'index.ts' ) ) ;
200+ plugins . push ( style ( { enableTailwind } ) ) ;
162201 plugins . push ( lessLoader ( ) ) ;
163202
164203 define = {
@@ -287,6 +326,16 @@ async function buildAll() {
287326 ) ,
288327 { target : 'web' , watch : watchAll }
289328 ) ,
329+ build (
330+ path . join ( extensionFolder , 'src' , 'webviews' , 'webview-side' , 'dataframe-renderer' , 'index.ts' ) ,
331+ path . join ( extensionFolder , 'dist' , 'webviews' , 'webview-side' , 'dataframeRenderer' , 'dataframeRenderer.js' ) ,
332+ { target : 'web' , watch : isWatchMode }
333+ ) ,
334+ build (
335+ path . join ( extensionFolder , 'src' , 'webviews' , 'webview-side' , 'vega-renderer' , 'index.ts' ) ,
336+ path . join ( extensionFolder , 'dist' , 'webviews' , 'webview-side' , 'vegaRenderer' , 'vegaRenderer.js' ) ,
337+ { target : 'web' , watch : isWatchMode }
338+ ) ,
290339 build (
291340 path . join ( extensionFolder , 'src' , 'webviews' , 'webview-side' , 'variable-view' , 'index.tsx' ) ,
292341 path . join ( extensionFolder , 'dist' , 'webviews' , 'webview-side' , 'viewers' , 'variableView.js' ) ,
@@ -301,6 +350,11 @@ async function buildAll() {
301350 path . join ( extensionFolder , 'src' , 'webviews' , 'webview-side' , 'data-explorer' , 'index.tsx' ) ,
302351 path . join ( extensionFolder , 'dist' , 'webviews' , 'webview-side' , 'viewers' , 'dataExplorer.js' ) ,
303352 { target : 'web' , watch : watchAll }
353+ ) ,
354+ build (
355+ path . join ( extensionFolder , 'src' , 'webviews' , 'webview-side' , 'integrations' , 'index.tsx' ) ,
356+ path . join ( extensionFolder , 'dist' , 'webviews' , 'webview-side' , 'integrations' , 'index.js' ) ,
357+ { target : 'web' , watch : watchAll }
304358 )
305359 ) ;
306360
0 commit comments