magento / pwa-studio

🛠Development tools to build, optimize and deploy Progressive Web Applications for Magento 2.
https://developer.adobe.com/commerce/pwa-studio/
Open Software License 3.0
1.06k stars 682 forks source link

[bug]: pwa-studio section missing from packages.json #2515

Closed fooman closed 4 years ago

fooman commented 4 years ago

Describe the bug pwa-studio section missing from packages.json when installed via create-pwa

To reproduce Note comment in local-intercept.js

 * This project has a section in its package.json:
 *    "pwa-studio": {
 *        "targets": {
 *            "intercept": "./local-intercept.js"
 *        }
 *    }

try to locate the above in a project based on create-pwa.

Expected behavior The above should exist.

Possible solutions https://github.com/magento/pwa-studio/pull/2514

Please complete the following device information:

Please let us know what packages this bug is in regards to:

m2-assistant[bot] commented 4 years ago

Hi @fooman. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


Jordaneisenburger commented 4 years ago

Hi @fooman ,

I think this happens because create-pwa scaffolds from 6.0.1 hence this is not included in the package.json.

awilcoxa commented 4 years ago

Created PWA-730 in Jira backlog for grooming

fooman commented 4 years ago

@awilcoxa I'd probably take the severity down on this one. It's possible to manually copy this into one's own package.json and there would currently be nothing in existence that would break due to it missing. Longer term it has more an educational impact on introducing a common way to customise pwa studio via targets.

wokakira commented 4 years ago

How would you use the local-intercept.js file?

fooman commented 4 years ago

@wokakira you could for example add a new route

function localIntercept(targets) {
    targets.of('@magento/venia-ui').routes.tap(routes => [
        ...routes,
        {
            name: 'Blog New',
            pattern: '/blog/:urlKey?',
            exact: false,
            path: '../../../../../../src/RootComponents/Blog'
        }
    ]);
}
module.exports = localIntercept;
quynhvv commented 4 years ago

@wokakira: You can try with steps as followings: 1. In the file at path: path_to_your_custom_project/package.json you declare as the following:

"pwa-studio": { "targets": { "intercept": "./local-intercept.js" } }

2. In the file at path: path_to_your_custom_project/local-intercept.js you declare as the following:

function localIntercept(targets) { targets.of('@magento/venia-ui').routes.tap(routes => [ ...routes, { name: 'Custom Title', pattern: '/custom-route', exact: true, path: 'path_to_your_custom_project/src/components/CustomComponent' } ]); return targets; } module.exports = localIntercept;

wokakira commented 4 years ago

Thanks @quynhvv @fooman