Download the PHP package wavevision/nette-webpack without Composer
On this page you can find all versions of the php package wavevision/nette-webpack. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wavevision/nette-webpack
More information about wavevision/nette-webpack
Files in wavevision/nette-webpack
Package nette-webpack
Short Description Webpack adapter for Nette framework.
License MIT
Informations about the package nette-webpack
Nette Webpack
Webpack adapter for Nette framework consisting of:
- DI extension
- entry point chunks resolver (uses webpack
manifest.json
) - UI components to render assets
<script>
and<link>
tags - webpack config helper to manage your setup consistently with
neon
files
Installation
Install the DI extension via Composer.
The webpack helper can be installed via Yarn
or npm
Usage
DI extension
Register DI extension in your app config.
You can configure the extension as follows (default values).
debugger: boolean
– enable Tracy panel with useful development informationdevServer.enabled: boolean
– serve assets fromwebpack-dev-server
devServer.url: string
–webpack-dev-server
public URLdir: string
– absolute path to webpack build directorydist: string
– webpack build directory nameentries: Record<string, boolean>
– webpack entry points that should be considered when resolving assetsmanifest: string
– webpack manifest name
Then, setup entry chunks.
Note: Entry chunks are resolved based on webpack
manifest.json
. You can also set chunks manually and/or separately withsetScripts
andsetStyles
methods.
Finally, render assets
in your layout.
Should you need it, you can inject and use following services to further customize your setup:
NetteWebpack
– provides basic methods to work with the extensionFormatAssetName
– formats and resolves asset URL based on provided nameFormatChunkName
– formats chunk names for specific content types and resolves their URL
Webpack helper
This simple utility will help you to manage your project setup and webpack configs consistently. It will also provide
you with pre-configured webpack-manifest-plugin to
generate manifest.json
with extra chunks
property that is used to dynamically resolve entry chunks in your application.
The helper constructor accepts following arguments:
neonPath?: string
– path to aneon
in whichwebpack
is configured (if not provided, default values will be used)wwwDir: string
– mandatory path to applicationwwwDir
manifestOptions?: WebpackManifestPlugin.Options
– if you need to customize manifest plugin setup, you can do it here
The returned class exposes following methods:
createManifestPlugin(): WebpackManifestPlugin
– creates manifest plugin instancegetDevServerPublicPath(): string
– returns resolvedwebpack-dev-server
URL withdist
included in pathgetDevServerUrl(): UrlWithParsedQuery
– returnswebpack-dev-server
parsed URL objectgetDist(): string
– returnsdist
parametergetEntries(): Record<string, boolean>
– returns records of configured webpack entriesgetEnabledEntries(): string[]
– returns list of webpack entries that havetrue
configuredgetManifest(): string
– returns webpack manifest file namegetOutputPath(): string
– returns resolved path to webpack output directoryparseNeonConfig<T extends NeonConfig>(): T
– returns parsedneon
config (throws error ifneonPath
is not defined)
Note: You can also import
Neon
helper if you want to parse and work with moreneon
files.
See example webpack config to see it all in action.
Credits
Many️ 🙏 to Jiří Pudil for his WebpackNetteAdapter which we used in our projects and served as an inspiration for this library.
All versions of nette-webpack with dependencies
latte/latte Version ^2.6
nette/di Version ^3.0
nette/http Version ^3.0
tracy/tracy Version ^2.7
wavevision/props-control Version ^6.0
wavevision/utils Version ^2.4