Skip to content

Commit

Permalink
changes to webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
SeboBlock committed Feb 13, 2025
1 parent 7c23694 commit b73be54
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 45 deletions.
2 changes: 1 addition & 1 deletion packages/webpack-sw6-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"url": "https://github.com/pixolith/webpack-plugins/issues"
},
"homepage": "https://github.com/pixolith/webpack-plugins/tree/master/packages/webpack-hook-plugin/#readme",
"gitHead": "da732cf67060679cb798bb2a70067ccfca0eedf7",
"gitHead": "7c23694f054ecadd0ac3f6cd2563de74142e6f3e",
"dependencies": {
"@babel/cli": "7.25.9",
"@babel/core": "^7.26.0",
Expand Down
91 changes: 47 additions & 44 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,4 @@
import Fs from 'fs';
import WebpackConfig from '@pixolith/webpack-sw6-config';

if (process.env.SHOPWARE_MODE === 'storefront') {
process.env.PUBLIC_PATH = './public';

// browserslist config in package.json
process.env.BROWSERSLIST_ENV = 'storefront';

// activate mobile device splitting
process.env.MEDIA_QUERIES = JSON.stringify({
'(min-width: 768px)': 'desktop',
'(min-width: 1024px)': 'desktop',
'(min-width: 1280px)': 'desktop',
'(min-width: 1440px)': 'desktop',
});
}

if (process.env.SHOPWARE_MODE === 'administration') {
process.env.PUBLIC_PATH = './public/bundles';

// browserslist config in package.json
process.env.BROWSERSLIST_ENV = 'administration';
}

let sharedVendorResourcePaths = Fs.existsSync('vendor/pxsw')
? ['vendor/pxsw/*/src/Resources/app/_global_resources/**/*.scss']
: [];

let sharedPluginResourcePaths = Fs.existsSync('custom/plugins')
? ['custom/plugins/Pxsw*/src/Resources/app/_global_resources/**/*.scss']
: [];

let uses = Fs.existsSync('custom/plugins/PxswProject/src/Resources/app/uses.scss')
? ['custom/plugins/PxswProject/src/Resources/app/uses.scss']
: Fs.existsSync('vendor/pxsw/project/src/Resources/app/uses.scss')
? ['vendor/pxsw/project/src/Resources/app/uses.scss']
: [];

process.env.RESOURCES_PATHS = JSON.stringify([
...uses,
...sharedVendorResourcePaths,
...sharedPluginResourcePaths,
]);

if (
!(
Expand All @@ -55,4 +12,50 @@ if (
process.exit(1);
}

export default WebpackConfig[process.env.SHOPWARE_MODE];
export default async () => {
if (process.env.SHOPWARE_MODE === 'storefront') {
process.env.PUBLIC_PATH = './public';

// browserslist config in package.json
process.env.BROWSERSLIST_ENV = 'storefront';

// activate mobile device splitting
process.env.MEDIA_QUERIES = JSON.stringify({
'(min-width: 768px)': 'desktop',
'(min-width: 1024px)': 'desktop',
'(min-width: 1280px)': 'desktop',
'(min-width: 1440px)': 'desktop',
});
}

if (process.env.SHOPWARE_MODE === 'administration') {
process.env.PUBLIC_PATH = './public/bundles';

// browserslist config in package.json
process.env.BROWSERSLIST_ENV = 'administration';
}

let sharedVendorResourcePaths = Fs.existsSync('vendor/pxsw')
? ['vendor/pxsw/*/src/Resources/app/_global_resources/**/*.scss']
: [];

let sharedPluginResourcePaths = Fs.existsSync('custom/plugins')
? ['custom/plugins/Pxsw*/src/Resources/app/_global_resources/**/*.scss']
: [];

let uses = Fs.existsSync('custom/plugins/PxswProject/src/Resources/app/uses.scss')
? ['custom/plugins/PxswProject/src/Resources/app/uses.scss']
: Fs.existsSync('vendor/pxsw/project/src/Resources/app/uses.scss')
? ['vendor/pxsw/project/src/Resources/app/uses.scss']
: [];

process.env.RESOURCES_PATHS = JSON.stringify([
...uses,
...sharedVendorResourcePaths,
...sharedPluginResourcePaths
]);

const WebpackConfig = await import('@pixolith/webpack-sw6-config');

return WebpackConfig[process.env.SHOPWARE_MODE === 'storefront' ? 'storefrontConfig' : 'administrationConfig'];
};

0 comments on commit b73be54

Please sign in to comment.