Skip to content

Commit

Permalink
fix(config): Disable source map generators for akamai deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed Apr 14, 2021
1 parent f6b54b6 commit d05b9ff
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions packages/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const gitRevisionPlugin = new (require('git-revision-webpack-plugin'))({
branch: true
});
const betaBranhces = ['master', 'qa-beta', 'ci-beta', 'prod-beta', 'main', 'devel'];
const akamaiBranches = ['prod-beta', 'prod-stable']

const getAppEntry = (rootFolder, isProd) => {
const jsAppEntry = isProd ? `${rootFolder}/src/entry.js` : `${rootFolder}/src/entry-dev.js`;
Expand All @@ -30,12 +31,14 @@ module.exports = (configurations) => {

const publicPath = `/${appDeployment}/${insights.appname}/`;
const appEntry = getAppEntry(configurations.rootFolder, process.env.NODE_ENV === 'production');
const generateSourceMaps = !akamaiBranches.includes(gitBranch);

/* eslint-disable no-console */
if (configurations.debug) {
console.log('~~~Using variables~~~');
console.log(`Root folder: ${configurations.rootFolder}`);
console.log(`Current branch: ${gitBranch}`);
!generateSourceMaps && console.log(`Source map generation for "${gitBranch}" deployment has been disabled.`)
console.log(`Beta branches: ${betaBranhces}`);
console.log(`Using deployments: ${appDeployment}`);
console.log(`Public path: ${publicPath}`);
Expand All @@ -57,6 +60,7 @@ module.exports = (configurations) => {
}),
plugins: plugins({
...configurations,
generateSourceMaps,
appDeployment,
insights,
publicPath
Expand Down
4 changes: 0 additions & 4 deletions packages/config/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ module.exports = ({
appName,
skipChrome2
}
}, {
test: /src\/.*\.js$/,
enforce: 'pre',
use: [ 'source-map-loader' ]
}, {
test: /src\/.*\.js$/,
exclude: /(node_modules|bower_components)/i,
Expand Down
2 changes: 1 addition & 1 deletion packages/config/src/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('module rules', () => {
const {
module
} = configBuilder({ appEntry: 'testEntry', appName: 'someName' });
expect(module.rules.length).toBe(7);
expect(module.rules.length).toBe(6);
});

test('first to be chrome-render-loader', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/config/src/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = ({
replacePlugin,
insights,
modules,
generateSourceMaps,
plugins
} = {}) => {
const HtmlWebpackPlugin = new(require('html-webpack-plugin'))({
Expand All @@ -47,7 +48,7 @@ module.exports = ({
] });

return [
SourceMapsPlugin,
...(generateSourceMaps ? [ SourceMapsPlugin ] : []),
ExtractCssWebpackPlugin,
CleanWebpackPlugin,
HtmlWebpackPlugin,
Expand Down
9 changes: 7 additions & 2 deletions packages/config/src/plugins.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import plugins from './plugins';

const HTML_WEBPACK = 3;
const REPLACE = 4;
const HTML_WEBPACK = 2;
const REPLACE = 3;

describe('plugins generations, no option', () => {
const enabledPlugins = plugins();

it('should generate plugins', () => {
expect(enabledPlugins.length).toBe(7);
});

it('should generate plugins with sourceMaps', () => {
const enabledPlugins = plugins({ generateSourceMaps: true });
expect(enabledPlugins.length).toBe(8);
});

Expand Down

0 comments on commit d05b9ff

Please sign in to comment.