Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving issue where assets never served for production builds #5

Merged

Conversation

joepagan
Copy link

@joepagan joepagan commented Dec 14, 2021

Description

HUnless I have misunderstood the setup process and some of my settings are incorrect, I believe the strpos values need to be reversed. Hard to believe that nobody has hit this yet, so I suspect I am the problem, if so sorry for the noise...

When debugging here, my $path never gets beyond this continue.

image

strpos(string $haystack, string $needle)

before:

if (strpos($path, $manifestKey) === false) {

after:

if (strpos($manifestKey, $path) === false) {

This change does appear to serve the correct assets, though comes with a likely unrelated issue:

Uncaught SyntaxError: 15
    at Jo (vendor.d63320e8.js:1)

@khalwat
Copy link
Contributor

khalwat commented Dec 14, 2021

hrm. At first glance, this does seem to be backward... but as you say, crazy no one has run into this yet. I will look at it futher.

@engram-design
Copy link

I'll mention that it's not an issue for me, purely because both values are the same, in most cases:

$path = 'js/main.js'
$manifestKey = 'js/main-legacy.js'

$path = 'js/main-legacy.js'
$manifestKey = 'js/main-legacy.js'

$path = 'js/main.js'
$manifestKey = 'js/main.js'

Might have something to do with my Vite config:

<?php
use craft\helpers\App;

return [
    'useDevServer' => App::env('ENVIRONMENT') === 'local',
    'manifestPath' => '@webroot/dist/manifest.json',
    'devServerPublic' => 'http://localhost:3000/',
    'serverPublic' => rtrim(App::env('BASE_URL'), '/') . '/dist/',
    'errorEntry' => 'js/app.js',
    'cacheKeySuffix' => '',
    'devServerInternal' => 'http://localhost:3000/',
    'checkDevServer' => true,
    'includeReactRefreshShim' => false,
    'criticalPath' => '',
    'criticalSuffix' => '',
];

But otherwise objectively, looks like the comparison isn't correct.

Damn PHP and it's inconsistent function arguments

@khalwat
Copy link
Contributor

khalwat commented Dec 14, 2021

Yeah I think my code is wrong, and exactly backward!

@khalwat khalwat merged commit 22badc9 into nystudio107:develop Dec 14, 2021
@khalwat
Copy link
Contributor

khalwat commented Dec 14, 2021

Thank you @joepagan !

khalwat pushed a commit to nystudio107/craft-vite that referenced this pull request Dec 14, 2021
…strpos()` which could cause it to not match properly in some setups ([#5](nystudio107/craft-plugin-vite#5))
@joepagan
Copy link
Author

Any time @khalwat feels weird doing something for you for once!

@joepagan joepagan deleted the hotfix/prod-assets-never-served branch December 14, 2021 22:19
khalwat pushed a commit that referenced this pull request Dec 16, 2021
khalwat pushed a commit to nystudio107/craft-vite that referenced this pull request Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants