diff options
Diffstat (limited to '.config/coc/extensions/node_modules/coc-css/esbuild.js')
| -rw-r--r-- | .config/coc/extensions/node_modules/coc-css/esbuild.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/.config/coc/extensions/node_modules/coc-css/esbuild.js b/.config/coc/extensions/node_modules/coc-css/esbuild.js new file mode 100644 index 0000000..bd64151 --- /dev/null +++ b/.config/coc/extensions/node_modules/coc-css/esbuild.js @@ -0,0 +1,51 @@ +const path = require('path') + +let entryPlugin = { + name: 'entry', + setup(build) { + build.onResolve({filter: /^(index|server)\.ts$/}, args => { + return { + path: args.path, + namespace: 'entry-ns' + } + }) + build.onLoad({filter: /.*/, namespace: 'entry-ns'}, args => { + let contents = '' + if (args.path == 'index.ts') { + contents = ` + import {activate} from './src/index' + export {activate} + ` + } else if (args.path == 'server.ts') { + contents = `require('./server/node/cssServerMain.ts')` + } else { + throw new Error('Bad path') + } + return { + contents, + resolveDir: __dirname + } + }) + } +} + +async function start() { + await require('esbuild').build({ + entryPoints: ['index.ts', 'server.ts'], + define: {'process.env.NODE_ENV': JSON.stringify("production")}, + bundle: true, + platform: 'node', + target: 'node12.16', + mainFields: ['module', 'main'], + minify: true, + sourcemap: true, + external: ['coc.nvim'], + outdir: path.resolve(__dirname, 'lib'), + plugins: [entryPlugin] + }) +} + +start().catch(e => { + console.error(e) +}) + |
