56 lines
1.1 KiB
TypeScript
56 lines
1.1 KiB
TypeScript
|
import { DefinePlugin } from 'webpack';
|
||
|
import * as nodeExternals from 'webpack-node-externals';
|
||
|
import * as copyPlugin from 'copy-webpack-plugin';
|
||
|
import { resolve } from 'path';
|
||
|
|
||
|
function transform_package(input: Buffer): string {
|
||
|
const pkg = JSON.parse(input.toString());
|
||
|
delete pkg['devDependencies'];
|
||
|
delete pkg['jest'];
|
||
|
pkg['scripts'] = {
|
||
|
start: 'node server.js'
|
||
|
};
|
||
|
return JSON.stringify(pkg);
|
||
|
}
|
||
|
|
||
|
export default {
|
||
|
entry: './src/main.ts',
|
||
|
plugins: [
|
||
|
new DefinePlugin({
|
||
|
PROD: JSON.stringify(true)
|
||
|
}),
|
||
|
new copyPlugin({
|
||
|
patterns: [
|
||
|
{
|
||
|
from: resolve(__dirname, 'package.json'),
|
||
|
to: resolve(__dirname, 'dist', 'package.json'),
|
||
|
transform: transform_package
|
||
|
},
|
||
|
{
|
||
|
from: resolve(__dirname, 'package-lock.json'),
|
||
|
to: resolve(__dirname, 'dist', 'package-lock.json')
|
||
|
}
|
||
|
]
|
||
|
})
|
||
|
],
|
||
|
module: {
|
||
|
rules: [
|
||
|
{
|
||
|
test: /\.ts?$/,
|
||
|
use: 'ts-loader'
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
externalsPresets: { node: true },
|
||
|
mode: 'production',
|
||
|
devtool: 'inline-source-map',
|
||
|
resolve: {
|
||
|
extensions: ['.ts', '.js']
|
||
|
},
|
||
|
output: {
|
||
|
filename: 'server.js',
|
||
|
path: resolve(__dirname, 'dist')
|
||
|
},
|
||
|
externals: [nodeExternals()]
|
||
|
};
|