Bundle sql worker with webpack
This commit is contained in:
parent
31a777a130
commit
1ca121aef5
9 changed files with 177 additions and 110 deletions
36
webpack-sql-worker.config.ts
Normal file
36
webpack-sql-worker.config.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2019-2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { resolve, join } from 'path';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { Configuration } from 'webpack';
|
||||
|
||||
const context = __dirname;
|
||||
|
||||
// A path relative to `ts/sql/` in `asar.unpacked`
|
||||
const libDir = join('..', '..', 'node_modules', 'better-sqlite3');
|
||||
const bindingFile = join(libDir, 'build', 'Release', 'better_sqlite3.node');
|
||||
|
||||
const workerConfig: Configuration = {
|
||||
context,
|
||||
mode: 'development',
|
||||
devtool: false,
|
||||
entry: ['./ts/sql/mainWorker.js'],
|
||||
target: 'node',
|
||||
output: {
|
||||
path: resolve(context, 'ts', 'sql'),
|
||||
filename: 'mainWorker.bundle.js',
|
||||
publicPath: './',
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js'],
|
||||
alias: {
|
||||
bindings: join(context, 'ts', 'sql', 'mainWorkerBindings.js'),
|
||||
},
|
||||
},
|
||||
externals: {
|
||||
'better_sqlite3.node': `commonjs2 ${bindingFile}`,
|
||||
},
|
||||
};
|
||||
|
||||
export default [workerConfig];
|
Loading…
Add table
Add a link
Reference in a new issue