API Docs¶
Manifests¶
Webpack manifests API.
-
class
pywebpack.manifests.
ManifestEntry
(name, paths)[source]¶ Represents a manifest entry.
Initialize manifest entry.
-
class
pywebpack.manifests.
ManifestFactory
(manifest_cls=<class 'pywebpack.manifests.Manifest'>, entry_cls=<class 'pywebpack.manifests.ManifestEntry'>)[source]¶ Manifest factory base class.
Initialize factory.
-
class
pywebpack.manifests.
ManifestLoader
(manifest_cls=<class 'pywebpack.manifests.Manifest'>, entry_cls=<class 'pywebpack.manifests.ManifestEntry'>)[source]¶ Loads a Webpack manifest (multiple types supported).
Initialize loader.
-
exception
pywebpack.manifests.
UnsupportedExtensionError
[source]¶ Manifest contains a file with an extension that is not supported.
-
class
pywebpack.manifests.
WebpackBundleTrackerFactory
(manifest_cls=<class 'pywebpack.manifests.Manifest'>, entry_cls=<class 'pywebpack.manifests.ManifestEntry'>)[source]¶ Manifest factory for webpack-bundle-tracker.
Initialize factory.
Projects¶
API for creating and building Webpack projects.
-
class
pywebpack.project.
WebpackBundleProject
(working_dir, project_template_dir, bundles=None, config=None, config_path=None, storage_cls=None, package_json_source_path='package.json')[source]¶ Build webpack project from multiple bundles.
Initialize templated folder.
- Parameters
working_dir – Path where config and assets files will be copied.
project_template_dir – Absolute path to the project folder.
bundles – List of
pywebpack.bundle.WebpackBundle
. This list can be statically defined if the bundles are known before hand, or dinamically generated usingpywebpack.helpers.bundles_from_entry_point()
so the bundles are discovered from the defined Webpack entrypoints exposed by other modules.config – Dictionary used to create the config.json file generated by pywebpack. It adds extra configuration at build time.
config_path – Path in working_dir where config.json will be written.
storage_cls – Storage class.
package_json_source_path – Path relative to project_template_dir to the project’s package.json.
-
property
aliases
¶ Get webpack resolver aliases from bundles.
-
property
bundles
¶ Get bundles.
-
property
config
¶ Inject webpack entry points from bundles.
-
create
(force=None)[source]¶ Create webpack project from a template.
This command collects all asset files from the bundles. It generates a new package.json by merging the package.json dependencies of each bundle.
-
property
dependencies
¶ Get package.json dependencies.
-
property
entry
¶ Get webpack entry points.
-
property
package_json
¶ Merge bundle dependencies into
package.json
.
-
property
package_json_source
¶ Read original package.json contents.
-
property
package_json_source_path
¶ Full path to the source package.json.
-
class
pywebpack.project.
WebpackProject
(path)[source]¶ API for building an existing Webpack project.
Initialize instance.
-
property
npmpkg
¶ Get API to NPM package.
-
property
path
¶ Path property.
-
property
project_path
¶ Get the project path.
-
property
-
class
pywebpack.project.
WebpackTemplateProject
(working_dir, project_template_dir, config=None, config_path=None, storage_cls=None)[source]¶ API for creating and building a webpack project based on a template.
Copies all files from a project template folder into a destination path and optionally writes a user provided config in JSON into the destination path as well.
Initialize templated folder.
- Parameters
working_dir – Path where config and assets files will be copied.
project_template_dir – absolute path to the project folder.
config – Dictionary used to create the config.json file generated by pywebpack. It adds extra configuration at build time.
config_path – Path in working_dir where config.json will be written.
storage_cls – Storage class.
-
property
config
¶ Get configuration dictionary.
-
property
config_path
¶ Get configuration path.
-
property
storage_cls
¶ Storage class property.
Bundles¶
Webpack bundle API.
-
class
pywebpack.bundle.
WebpackBundle
(path, entry=None, dependencies=None, devDependencies=None, peerDependencies=None, aliases=None)[source]¶ Webpack bundle.
Initialize webpack bundle.
- Parameters
path – Absolute path to the folder where the assets are located.
entry – webpack entry; it indicates which modules webpack should use to begin building out its internal dependency graph.
dependencies – npm dependencies.
devDependencies – npm dev dependencies.
peerDependencies – npm peer dependencies.
aliases – Webpack resolver aliases.
Helpers¶
Webpack bundle API.