Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Krzeszowiak committed Jul 3, 2019
1 parent 9bf37b2 commit 7355c9e
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 801 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
config.js
build.js

# Created by https://www.gitignore.io/api/osx,node,windows,visualstudiocode
# Edit at https://www.gitignore.io/?templates=osx,node,windows,visualstudiocode
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ modules: [
{
name: 'foo/bar',
create: true,
exclude: ['requirejs/require'],
exclude: ['bundles/common'],
include: ['foo/bar/baz'],
},
];
Expand All @@ -77,7 +77,7 @@ modules: [
Promise.resolve({
name: 'foo/bar',
create: true,
exclude: ['requirejs/require'],
exclude: ['bundles/common'],
include: ['foo/bar/baz'],
}),
];
Expand Down
779 changes: 0 additions & 779 deletions build.js

This file was deleted.

2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if (program.generate) {
}

try {
require('./lib/optimize')(program.config, program.dir);
require('./lib/bundle')(program.config, program.dir);
} catch (error) {
console.error(error);
process.exit(1);
Expand Down
28 changes: 14 additions & 14 deletions config.sample.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const category = require('magepack/lib/module/category');
const checkout = require('magepack/lib/module/checkout');
// const checkout = require('magepack/lib/module/checkout');
const cms = require('magepack/lib/module/cms');
const customer = require('magepack/lib/module/customer');
const pdp = require('magepack/lib/module/pdp');
Expand All @@ -18,36 +18,36 @@ module.exports = {
browser =>
category(browser, {
url: `${baseUrl}/women/tops-women/jackets-women.html`,
excludeRegExp: /^\.|amazon|smile|klarna/i,
}),
browser =>
checkout(browser, {
url: {
product: `${baseUrl}/overnight-duffle.html`,
cart: `${baseUrl}/checkout/cart/`,
checkout: `${baseUrl}/checkout/`,
},
excludeRegExp: /^\.|amazon|smile|klarna/i,
excludeRegExp: /^\.|amazon|smile|klarna|Magento_Checkout\/js\/view\/minicart/i,
}),
// browser =>
// checkout(browser, {
// url: {
// product: `${baseUrl}/overnight-duffle.html`,
// cart: `${baseUrl}/checkout/cart/`,
// checkout: `${baseUrl}/checkout/`,
// },
// excludeRegExp: /^\.|amazon|smile|klarna/i,
// }),
browser =>
cms(browser, {
url: baseUrl,
excludeRegExp: /^\.|amazon|smile|klarna/i,
excludeRegExp: /^\.|amazon|smile|klarna|Magento_Checkout\/js\/view\/minicart/i,
}),
browser =>
customer(browser, {
url: `${baseUrl}/customer/account/login/`,
email: '[email protected]',
password: 'Testing123',
excludeRegExp: /^\.|amazon|smile|klarna/i,
excludeRegExp: /^\.|amazon|smile|klarna|Magento_Checkout\/js\/view\/minicart/i,
}),
browser =>
pdp(browser, {
url: [
`${baseUrl}/olivia-1-4-zip-light-jacket.html`,
`${baseUrl}/overnight-duffle.html`,
],
excludeRegExp: /^\.|amazon|smile|klarna/i,
excludeRegExp: /^\.|amazon|smile|klarna|Magento_Checkout\/js\/view\/minicart/i,
}),
],
};
2 changes: 1 addition & 1 deletion lib/baseConfig.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
optimize: 'uglify2',
inlineText: true,
inlineText: false,
logLevel: 2,
preserveLicenseComments: false,
deps: [],
Expand Down
4 changes: 2 additions & 2 deletions lib/optimize.js → lib/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ module.exports = async (configPath, dirPath) => {

await fs.appendFile(fileName, contents);

console.log('Removing temporary directory for static files...');
await fs.remove(baseUrl);
// console.log('Removing temporary directory for static files...');
// await fs.remove(baseUrl);

console.log('Finished optimized bundling.');
},
Expand Down
5 changes: 4 additions & 1 deletion lib/dependencies/collect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ module.exports = (page, excludeRegExp = /^\./) =>
window.require.s.contexts._.defined
).filter(
dependency =>
dependency.indexOf('mixins!') !== 0
dependency.indexOf('mixins!') === -1 &&
dependency.indexOf('text!') === -1 &&
dependency !== 'text' &&
dependency !== 'mage/gallery/gallery'
);

resolve(dependencies);
Expand Down
2 changes: 1 addition & 1 deletion lib/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ module.exports = async (outputPath, userConfigPath) => {

fs.outputFile(
path.resolve(outputPath),
`module.exports = ${stringify(buildConfig)}`
`module.exports = ${stringify(buildConfig, { indent: ' ' })}`
);
};

0 comments on commit 7355c9e

Please sign in to comment.