-
Notifications
You must be signed in to change notification settings - Fork 3
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
Webpack Helpers v1 Beta: Webpack 5, addFilter() #205
base: main
Are you sure you want to change the base?
Conversation
Fix error in presets test "process" mocking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is some great work! I'd like to test this on one or two projects, but here's some ad hoc feedback.
|
This is really awesome! Just gave it a quick "update and see what happens" test locally on a project. BuildUsing the production preset, things were pretty smooth - one deprecation nag around a destructured import, and I needed to specifically install Dev ServerDevServer seems to have more breaking changes, at least for our setup. I'll have to look into it further when I have time, but our array of entries mapped to devServers are no longer happy to use the same port: Relevant part of the config is here devServer return choosePort( 9090 ).then( ( port ) => entries.map( ( entry ) => {
return presets.development( {
...common,
devServer: {
...devServer,
port,
},
...entry,
output: {
...entry.output,
publicPath: `https://${ host }:${ port }/${ entry.name.toLowerCase() }/`,
},
} );
} ) );
}; where each item in entrypointsconst example = {
name: 'example',
entry: {
'lorem': filePath( 'content/plugins/example/assets/src/index.js' ),
},
output: {
path: filePath( 'content/plugins/example/assets/build' ),
},
}; Something like this seems to work, with a couple of angry messages about running webpack twice for some entrypoints, but I haven't yet had a chance to dig into it too much. potential devServerreturn entries.map( ( entry, index ) =>
choosePort( 9090 + index ).then( ( port ) => presets.development( {
...common,
devServer: {
...devServer,
port,
},
...entry,
output: {
...entry.output,
publicPath: `https://${ host }:${ port }/${ entry.name.toLowerCase() }/`,
},
} ) )
); |
Summing up a long thread in Slack with @kucrut that we're running into this: webpack/webpack-dev-server#2792 when using multiple entries in one config. |
What does that mean exactly? Quite a few Altis projects are using the actual "local", that is, const host = 'my-project.altis.dev';
const devServer = {
allowedHosts: [
`.${ host }`,
],
host,
https: {
key: readFileSync( filePath( 'vendor/altis/local-server/docker/ssl.key' ) ),
cert: readFileSync( filePath( 'vendor/altis/local-server/docker/ssl.cert' ) ),
},
}; Are we planning on supporting that still? |
@tfrommen I don't think we've made any changes which would break that usage. The intent is absolutely to support that. |
This resolves an issue where multi-config entries would only output a manifest containing the entries from the first exported config. The origin of this issue is that we cannot define a devServer on every multi-config array, or DevServer v4 will error. But without defining a devServer we did not usually have the information needed to deduce a publicPath, and therefore did not insert the manifest plugin in subsequent configs. Remove test for not setting manifest plugin
contenthash is not recommended in dev mode, and hash, the value we previously used, has been renamed fullhash for clarity.
…ries See Webpack DevServer issue 2792.
…er changes You need to manually include the runtimeChunk if you do this.
…e output folder This permits minimal-config multi-config dev builds which stack multiple config output into one manifest. Without a patch like this, the second dev config would get the publicPath "auto".
I see there has been some discussion here on some of the issues i've run into... and maybe some fixes too. But I'll note my workarounds in case they're helpful.
|
This works well, and I always recommend labeling each config with a
The production manifest would look like this: {
"editor.js": "./editor.hash.js",
"editor.css": "./editor.hash.css",
"frontend.js": "./frontend.hash.js",
"frontend.css": "./frontend.hash.css",
"big-script-for-that-one-complex-page.js": "./big-script-for-that-one-complex-page.hash.js"
} If you then run {
"editor.js": "http://localhost:8080/editor.js"
} The way asset loader works now, if you use $active_manifest = get_active_manifest( [ 'dev-manifest.json', 'prod-manifest.json' ] );
Asset_Loader\enqueue_asset( $active_manifest, 'editor.js' );
Asset_Loader\enqueue_asset( $active_manifest, 'frontend.js' ); then If we use |
Something that was asked on a call. If you have to run multiple configs individually, can you just open up a new terminal tab and run the other config over there? And the answer is kind of. It works but hot module reloading fails for the second JS file loaded. I tried loading both only a single runtime JS file, and also multiple but no luck. Maybe there is a workaround? |
Pin block-editor-hmr to include a bugfix for a regression in files which do not export settings
Remaining tasks for 1.0:
|
This PR changes a few small things.... 😅
addFilter
more WP-style system I came up with while discussing an issue with @tfrommenKnown issues
auto
in the paths due to apublicPath
change; need to check that.