2020-01-22 23:47:34 +02:00
|
|
|
const path = require('path');
|
2020-01-25 18:13:32 +02:00
|
|
|
const webpack = require('webpack');
|
2020-01-22 23:47:34 +02:00
|
|
|
const nodeExternals = require('webpack-node-externals');
|
|
|
|
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
|
|
const { NODE_ENV = 'production' } = process.env;
|
|
|
|
|
|
|
|
const allowList = [/^netlify-cms-lib-util/];
|
|
|
|
|
|
|
|
module.exports = {
|
2020-03-02 14:42:29 +01:00
|
|
|
entry: { index: path.join('src', 'index.ts'), middlewares: path.join('src', 'middlewares.ts') },
|
2020-01-22 23:47:34 +02:00
|
|
|
mode: NODE_ENV,
|
|
|
|
target: 'node',
|
|
|
|
devtool: 'source-map',
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, 'dist'),
|
2020-03-02 14:42:29 +01:00
|
|
|
filename: '[name].js',
|
|
|
|
libraryTarget: 'commonjs2',
|
2020-01-22 23:47:34 +02:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
plugins: [new TsconfigPathsPlugin()],
|
|
|
|
extensions: ['.ts', '.js'],
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
use: ['ts-loader'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
externals: [
|
|
|
|
nodeExternals({ whitelist: allowList }),
|
|
|
|
nodeExternals({
|
|
|
|
whitelist: allowList,
|
|
|
|
modulesDir: path.resolve(__dirname, path.join('..', '..', 'node_modules')),
|
|
|
|
}),
|
|
|
|
],
|
2020-01-25 18:13:32 +02:00
|
|
|
plugins: [new webpack.BannerPlugin({ banner: '#!/usr/bin/env node', raw: true })],
|
2020-01-22 23:47:34 +02:00
|
|
|
};
|