sabbelasichon / typo3_encore

Use Webpack Encore within TYPO3
Other
108 stars 19 forks source link

TYPO3 Encore and typo3/cms-composer-installers v4 #134

Closed fsuter closed 2 years ago

fsuter commented 2 years ago

I have a TYPO3 v11 project using the upcoming v4 of typo3/cms-composer-installers. With the new installer script, the assets are not in public/typo3conf/ext/my_extension/Resources/Public anymore, but accessible via symlinks in public/_assets, with the symlinks being named with some kind of hashes. How do you point to assets with this new system? How should a configuration (such as the one below) be updated?

const config = Encore
    .setOutputPath('Resources/Public/Assets')
    .setPublicPath('/typo3conf/ext/catalog_package/Resources/Public/Assets')
    .setManifestKeyPrefix('Assets/')
    .addEntry('app', './Resources/Private/Assets/JavaScript/main.js')
    ...

Sorry if this has been answered elsewhere already.

sabbelasichon commented 2 years ago

Thanks. Need to have a look at the version of typo3/cms-composer-installers

fsuter commented 2 years ago

One solution (or is more of a workaround?) proposer by @avogt1701 in https://github.com/TYPO3/CmsComposerInstallers/issues/131 is to redirect the output of the build to public/build instead of inside an extension. To be complete, in case anyone wants to implement this solution, here is how the configuration can look like. First the webpack configuration (webpack.config.js):

const config = Encore
    .setOutputPath('../../public/build')
    .setPublicPath('/build')
    ...

The first path is relative to where the webpack.config.js file is located, the second is absolute (within the web root). The TypoScript constants need to be adapted too:

plugin.tx_typo3encore {
    settings {
        # These paths are relative to the web root (public) directory
        entrypointJsonPath = build/entrypoints.json
        manifestJsonPath = build/manifest.json
    }
}
sabbelasichon commented 2 years ago

This seems the best solution so far. Would you like to add your insights into the Readme? That would be very nice. Thanks for your work.

rintisch commented 2 years ago

@fsuter Thanks for sharing!

fsuter commented 2 years ago

This seems the best solution so far. Would you like to add your insights into the Readme? That would be very nice. Thanks for your work.

Done with https://github.com/fsuter/typo3_encore/commit/d551b48364b9015d33f713d88c2ee1c04e7f1a4c