-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #605 from martpie/esbuild
ESBuild
- Loading branch information
Showing
50 changed files
with
1,100 additions
and
1,266 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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,143 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
import esbuild from 'esbuild'; | ||
import postCssPlugin from 'esbuild-plugin-postcss2'; | ||
import esbuildPluginSvg from 'esbuild-plugin-svg'; | ||
|
||
import postCssImport from 'postcss-import'; | ||
import postCssNested from 'postcss-nested'; | ||
import postCssUrl from 'postcss-url'; | ||
|
||
const shouldWatch = process.argv.includes('--watch'); // infinite watch loop | ||
const isProduction = process.argv.includes('--production'); | ||
const minify = !shouldWatch && isProduction; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Helpers | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
|
||
// const onWatch = (name) => { | ||
// /** @type esbuild.WatchMode */ | ||
// const watchMode = { | ||
// onRebuild: (_errors, results) => { | ||
// console.log(`${name} rebuilt with ${results.errors.length} errors and ${results.warnings.length} warnings`); | ||
// }, | ||
// }; | ||
|
||
// return watchMode; | ||
// }; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Main process config | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
|
||
/** @type esbuild.BuildOptions */ | ||
const configMain = { | ||
entryPoints: ['./src/main/main.ts'], | ||
bundle: true, | ||
outfile: 'dist/main/bundle.js', | ||
platform: 'node', | ||
target: 'node16.5', | ||
external: ['electron'], | ||
// watch: shouldWatch ? onWatch('main') : null, | ||
incremental: shouldWatch, | ||
minify, | ||
define: { | ||
'process.env.NODE_ENV': isProduction ? '"production"' : '"development"', | ||
}, | ||
}; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Renderer process config | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
|
||
/** @type esbuild.BuildOptions */ | ||
let configRenderer = { | ||
entryPoints: ['./src/renderer/main.tsx'], | ||
bundle: true, | ||
outfile: 'dist/renderer/bundle.js', | ||
platform: 'browser', | ||
target: 'chrome91', | ||
external: ['electron', 'fs', 'stream', 'path', 'platform', 'assert', 'os', 'constants', 'util', 'events'], | ||
// watch: shouldWatch ? onWatch('renderer') : null, | ||
incremental: shouldWatch, | ||
minify, | ||
sourcemap: !isProduction, | ||
define: { | ||
'process.env.NODE_ENV': isProduction ? '"production"' : '"development"', | ||
}, | ||
plugins: [ | ||
esbuildPluginSvg(), | ||
postCssPlugin.default({ | ||
plugins: [postCssImport, postCssNested, postCssUrl({ url: 'inline' })], | ||
// https://github.com/martonlederer/esbuild-plugin-postcss2/pull/30 | ||
modules: true, | ||
rootDir: process.cwd(), | ||
sassOptions: {}, | ||
lessOptions: {}, | ||
stylusOptions: {}, | ||
writeToFile: true, | ||
}), | ||
], | ||
loader: { | ||
'.eot': 'file', | ||
'.woff': 'file', | ||
'.woff2': 'file', | ||
'.svg': 'file', | ||
'.ttf': 'file', | ||
}, | ||
}; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Bundlers (prod + dev) | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
|
||
async function bundle() { | ||
try { | ||
await Promise.all([esbuild.build(configMain), esbuild.build(configRenderer)]); | ||
console.log('[museeks] built'); | ||
} catch { | ||
process.exit(1); | ||
} | ||
} | ||
|
||
async function bundleWatch() { | ||
try { | ||
let [resultMain, resultRenderer] = await Promise.all([esbuild.build(configMain), esbuild.build(configRenderer)]); | ||
|
||
console.log('[museeks] built, listening to change...'); | ||
|
||
// Custom watcher | ||
// See https://github.com/martonlederer/esbuild-plugin-postcss2/issues/19 | ||
if (shouldWatch) { | ||
fs.watch(path.join('.', 'src'), { recursive: true }, async (eventType, filename) => { | ||
console.log(`[museeks][${eventType}] ${filename}`); | ||
try { | ||
await Promise.all([resultMain.rebuild(), resultRenderer.rebuild()]); | ||
} catch { | ||
// nothing | ||
} | ||
console.log('[museeks] rebuilt'); | ||
}); | ||
} | ||
} catch { | ||
// nothing | ||
} | ||
} | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Fire things up | ||
|-------------------------------------------------------------------------- | ||
*/ | ||
|
||
shouldWatch ? bundleWatch() : bundle(); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
height: 100%; | ||
} | ||
|
||
.main-content { | ||
.mainContent { | ||
width: 100%; | ||
flex: 1 1 auto; | ||
position: relative; | ||
|
This file contains 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
This file contains 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
6 changes: 3 additions & 3 deletions
6
src/renderer/components/CustomScrollbar/CustomScrollbar.module.css
This file contains 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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
.render-view { | ||
.renderView { | ||
overflow-x: hidden !important; /* Overriding react-custom-scrollbars */ | ||
margin-bottom: 0 !important; /* there is no overflow-x */ | ||
} | ||
|
||
.vertical-track { | ||
.verticalTrack { | ||
right: 8px; | ||
background-color: var(--scrollbar-track); | ||
top: 8px; | ||
bottom: 8px; | ||
z-index: 10; | ||
} | ||
|
||
.vertical-thumb { | ||
.verticalThumb { | ||
background-color: var(--scrollbar-thumb); | ||
} |
This file contains 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
Oops, something went wrong.