Skip to content

Commit

Permalink
Update serviceworker.config.js webpack
Browse files Browse the repository at this point in the history
Motivation: switch to new weback plugins & bring in line with master
  • Loading branch information
rgomezp committed Jul 10, 2024
1 parent f985ae3 commit 98f3061
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions build/config/serviceworker.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const webpack = require('webpack');
const path = require('path');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const { CheckerPlugin } = require('awesome-typescript-loader');
const TerserPlugin = require('terser-webpack-plugin');

const env = process.env.ENV || "production";
const buildOrigin = process.env.BUILD_ORIGIN || "localhost";
Expand All @@ -15,10 +14,8 @@ const noDevPort = process.env.NO_DEV_PORT;
const tests = process.env.TESTS;
const sdkVersion = process.env.npm_package_config_sdkVersion;

async function getWebpackPlugins() {
function getWebpackPlugins() {
const plugins = [
new CheckerPlugin(),
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.DefinePlugin({
__BUILD_TYPE__: JSON.stringify(env),
__BUILD_ORIGIN__: JSON.stringify(buildOrigin),
Expand Down Expand Up @@ -80,9 +77,8 @@ async function generateWebpackConfig() {
mode: isProdBuild ? "production" : "development",
optimization: {
minimizer: [
new UglifyJsPlugin({
sourceMap: true,
uglifyOptions: {
new TerserPlugin({
terserOptions: {
sourceMap: true,
compress: {
drop_console: false,
Expand Down Expand Up @@ -116,9 +112,9 @@ async function generateWebpackConfig() {
exclude: /node_modules/,
use: [
{
loader: "awesome-typescript-loader",
loader: "ts-loader",
options: {
configFileName: "build/config/tsconfig.es6.json"
configFile: "build/config/tsconfig.es6.json"
}
},
]
Expand All @@ -134,8 +130,8 @@ async function generateWebpackConfig() {
]
},
devtool: "source-map",
plugins: await getWebpackPlugins(),
plugins: getWebpackPlugins(),
}
}

module.exports = generateWebpackConfig();
module.exports = generateWebpackConfig();

0 comments on commit 98f3061

Please sign in to comment.