51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
const path = require('path');
|
|
const nodeExternals = require('webpack-node-externals');
|
|
const slsw = require('serverless-webpack');
|
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
const TsConfigPathsPlugin = require('awesome-typescript-loader').TsConfigPathsPlugin;
|
|
const CopyPlugin = require("copy-webpack-plugin");
|
|
|
|
|
|
const isLocal = slsw.lib.webpack.isLocal;
|
|
const stage = slsw.lib.options.stage;
|
|
|
|
console.log('[Webpack - RUN]', new Date());
|
|
console.log('[Webpack - RUN] Entry', slsw.lib.entries);
|
|
console.log('[Webpack - RUN] Stage', stage);
|
|
|
|
module.exports = {
|
|
mode: isLocal ? 'development' : 'production',
|
|
entry: slsw.lib.entries,
|
|
externals: [nodeExternals({
|
|
allowlist:["axios"],
|
|
})],
|
|
devtool: 'source-map',
|
|
resolve: {
|
|
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
|
|
plugins: [new TsConfigPathsPlugin()],
|
|
},
|
|
output: {
|
|
libraryTarget: 'commonjs2',
|
|
path: path.join(__dirname, '.webpack'),
|
|
filename: '[name].js',
|
|
},
|
|
target: 'node',
|
|
module: {
|
|
rules: [
|
|
// all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
|
|
{ test: /\.tsx?$/, loader: 'awesome-typescript-loader', options: { transpileOnly: true }, exclude: /node_modules/ },
|
|
],
|
|
},
|
|
plugins: [new ForkTsCheckerWebpackPlugin(),
|
|
new CopyPlugin({
|
|
patterns: [
|
|
{ from: "node_modules/axios", to: "node_modules/axios" },
|
|
],
|
|
}),],
|
|
optimization: {
|
|
minimize: false, // <---- disables uglify.
|
|
nodeEnv: stage,
|
|
},
|
|
};
|