-
Notifications
You must be signed in to change notification settings - Fork 433
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 #1451 from geoman-io/fix/1444v2
Improve esbuild bundle script to watch css changes and output sourcemaps
- Loading branch information
Showing
11 changed files
with
91 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as esbuild from 'esbuild'; | ||
import fs from 'fs'; | ||
|
||
const plugins = [{ | ||
name: 'my-plugin', | ||
setup(build) { | ||
let count = 0; | ||
build.onEnd(({ errors, warnings }) => { | ||
count++; | ||
const message = errors.length === 0 && warnings.length === 0 | ||
? 'Build completed.' | ||
: `Build completed with ${errors.length} error(s) and ${warnings.length} warning(s).`; | ||
console.log(`[BUILD #${count.toString().padStart(3, '0')}]:`, message); }); | ||
}, | ||
}]; | ||
|
||
const buildOptions = { | ||
bundle: true, | ||
entryPoints: ['./src/js/L.PM.js'], | ||
loader: { | ||
'.js': 'jsx', | ||
'.css': 'css', | ||
'.svg': 'dataurl' }, | ||
minify: true, | ||
outfile: './dist/leaflet-geoman.js', | ||
//plugins: plugins, | ||
sourcemap: true, | ||
} | ||
|
||
const ctx = await esbuild.context({ ...buildOptions, plugins }); | ||
|
||
if (process.env.DEV) { | ||
await ctx.watch(); | ||
console.log('watching...'); | ||
const { host, port } = await ctx.serve({ | ||
port: 5500, | ||
servedir: '.', | ||
fallback: "./index.html" | ||
}); | ||
console.log(`Serving app at ${host}:${port}.`); | ||
} else { | ||
await ctx.rebuild(); | ||
ctx.dispose(); | ||
fs.copyFileSync('leaflet-geoman.d.ts', './dist/leaflet-geoman.d.ts'); | ||
fs.copyFileSync('./dist/leaflet-geoman.js', './dist/leaflet-geoman.min.js'); | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,4 @@ export default { | |
fi, | ||
ko, | ||
ky, | ||
}; | ||
}; |
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