mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-19 10:00:06 +00:00
chore(build): update webpack config to minify built code
This commit is contained in:
@@ -1,49 +1,57 @@
|
|||||||
const path = require("path");
|
const path = require('path')
|
||||||
const webpack = require("webpack");
|
const webpack = require('webpack')
|
||||||
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
|
const terserPlugin = require('terser-webpack-plugin')
|
||||||
|
|
||||||
const browserConfig = {
|
const browserConfig = {
|
||||||
entry: "./src/index.ts",
|
entry: './src/index.ts',
|
||||||
devtool: "inline-source-map",
|
devtool: 'inline-source-map',
|
||||||
mode: "development",
|
mode: 'production',
|
||||||
optimization: {
|
optimization: {
|
||||||
minimize: false,
|
minimizer: [
|
||||||
|
new terserPlugin({
|
||||||
|
cache: true,
|
||||||
|
parallel: true,
|
||||||
|
sourceMap: true,
|
||||||
|
terserOptions: {}
|
||||||
|
})
|
||||||
|
]
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.ts?$/,
|
test: /\.ts?$/,
|
||||||
use: "ts-loader",
|
use: 'ts-loader',
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [".ts", ".js"],
|
extensions: ['.ts', '.js']
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
filename: "index.js",
|
filename: 'index.js',
|
||||||
path: path.resolve(__dirname, "build"),
|
path: path.resolve(__dirname, 'build'),
|
||||||
libraryTarget: "umd",
|
libraryTarget: 'umd',
|
||||||
library: "SASjs",
|
library: 'SASjs'
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/),
|
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/),
|
||||||
new webpack.SourceMapDevToolPlugin({
|
new webpack.SourceMapDevToolPlugin({
|
||||||
filename: null,
|
filename: null,
|
||||||
exclude: [/node_modules/],
|
exclude: [/node_modules/],
|
||||||
test: /\.ts($|\?)/i,
|
test: /\.ts($|\?)/i
|
||||||
}),
|
}),
|
||||||
],
|
new webpack.IgnorePlugin(/\/iconv-loader$/)
|
||||||
};
|
]
|
||||||
|
}
|
||||||
|
|
||||||
const nodeConfig = {
|
const nodeConfig = {
|
||||||
...browserConfig,
|
...browserConfig,
|
||||||
target: "node",
|
target: 'node',
|
||||||
output: {
|
output: {
|
||||||
...browserConfig.output,
|
...browserConfig.output,
|
||||||
path: path.resolve(__dirname, "build", "node"),
|
path: path.resolve(__dirname, 'build', 'node')
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = [browserConfig, nodeConfig];
|
module.exports = [browserConfig, nodeConfig]
|
||||||
|
|||||||
Reference in New Issue
Block a user