L O A D I N G

Project Status

npmnpm downloads

buildbuild push package

check typeslinttest

code coverage

deploy web documentationweb documentation

Open in CodeSandbox

Use case

The main goal of This plugin is providing a generic module bundler and workflow for all your development use cases in any project related to the web or node. All native web types like html, css and JavaScript are supported natively in their latest language specification through preconfigured transpiler.

Features

  • Complete and flexible configured wrapper for webpack5+ with many automatically determined pre configurations.
  • Completely adaptable for your needs.
  • Targets library and web bundle building out of the box.
  • Only one configuration file (your already existing package.json) for all needed customisations needed.
  • Many uses-cases are preconfigured and mostly works out of the box for your project:
    • Preconfigured preprocessing for css (PostCSS), javaScript (Babel, Flow) and any generic text (template) file (in ejs) with any number of precompile/render steps for optimal runtime performance.
    • Preconfigured postprocessing for css (Minification), JavaScript (Minification), Images (Compression)
    • Image sprite handling: Combine your images and never manage sprites by hand again.
    • Polymorphic testing on dom in browsers and/or node through weboptimizer/browser
    • Linting and TypeChecking with Flow on css and javaScript
    • Automatic API-Documentation generation for javaScript
    • Various pre configured and adaptable implemented concepts for building development-, production-, testing-, errorhandler and/or vendor bundles.
    • Support for building libraries with well defined (UMD, AMD, commonjs...) external, dependencies (preconfigured extendable weback configuration)
    • Support for building and shimming a whole package managed application structure to build for various target environments like browsers or node (preconfigured extendable weback configuration)
    • Generic support for all known favicon types using only one png file as source (watching, compressing and auto-generating integrated)
    • Brings offline support though service worker to your application without any needed manual intervention!
    • Many development helper:
      • Automatic watching and (re-)building on any assets through cross platform file watching
      • Preconfigured local webserver with websocket connections to livereload you browser when any asset has changed (webpack-dev-server).
      • Preconfigured hot module replacement integration to update parts of your library/application with no siteeffects in a generic way without even the need to refresh your browser
      • Automaticaly watch and integrate any css updates trough hot module replacements in app which will be shiped through the development server.

Installation

You can install via package manager, simply download the compiled version as zip file here and inject or request via CDN in HTML:

npm install weboptimizer

Configuration

First you should specify some tasks/use-cases you want to use in you project. You can do this in your package.json. All supported scripts and some useful compositions are listed below:

...
"scripts": {
    ...
    "build": "weboptimizer build",
    "build:stats": "weboptimizer build --profile --json >/tmp/stat.json && echo 'Results successfully written to \"/tmp/stat.json\".'",
    "check": "yarn check:types; yarn lint",
    "check:types": "weboptimizer check:types",
    "clear": "weboptimizer clear",
    "document": "weboptimizer document",
    "lint": "weboptimizer lint",
    "postinstall": "weboptimizer build",
    "preinstall": "weboptimizer preinstall",
    "serve": "weboptimizer serve",
    "start": "npm run serve",
    "test": "weboptimizer test",
    "test:browser": "weboptimizer test:browser",
    "watch": "weboptimizer build --watch",
    ...
},
...

You can easily run any specified script via npm's command lint interface:

npm run build -debug
npm run lint
npm run watch -debug
npm run serve
...

If you want to configure your application to change any of the expected default source, target, asset or build paths do it in your package.json:

...
"webOptimizer": {
    ...
    "path": {
        ...
        "apiDocumentation": "apiDocumentation/",
        "source": {
            ...
            "asset": {
                ...
                "cascadingStyleSheet": "cascadingStyleSheet/",
                "data": "data/",
                "favicon": "favicon.png",
                "font": "font/",
                "image": "image/",
                "javaScript": "javaScript/",
                "publicTarget": "",
                "template": "template/"
                ..
            },
            ...
        },
        "ignore": ["node_modules", ".git"],
        "manifest": "manifest.appcache",
        "target": {
            ...
            "base": "dist/",
            ...
        },
        "tidyUp": ["crap"],
        ...
    },
    ...
},
...

It's recommended to first specify if you're writing a library (preserve external dependencies not managed within current project) or an application (everything should be bundled including external libraries) since many preconfigurations are targeting on this two different use cases. Anyway you can customize each configuration preset by hand.

...
"webOptimizer": {
    ...
    "library": false,
    ...
},
...

You can even reference any value or evaluate any configuration value dynamically though a complete javaScript compatible evaluation mechanism:

...
"webOptimizer": {
    ...
    "path": {
        ...
        "source": {
            ...
            "base": "/",
            "asset": {
                ...
                "cascadingStyleSheet": "cascadingStyleSheet/",
                "template": {
                    "__evaluate__": "self.debug ? '' : self.path.source.base"
                },
                ...
            },
            ...
        },
        ...
    },
    ...
    "offline": {
        ...
        "externals": [
            ...
            {"__evaluate__": "self.path.source.asset.cascadingStyleSheet"},
            "onlineAvailable.txt",
            ...
        ],
        ...
    },
    ...
},
...

You can even execute scripts to determine a value:

...
"webOptimizer": {
    ...
    "path": {
        ...
        "source": {
            ...
            "base": "/",
            "asset": {
                ...
                "template": {
                    "__execute__": "test = self.path.source.base; if (test.endsWith('js')) return 'bar/';return 'foo/'"
                },
                ...
            },
            ...
        },
        ...
    },
    ...
},
...

For all available configuration possibilities please have a look at the package.json file in this project since these values will be extended on runtime.

Additionally its even possible to overwrite any value on runtime via a complete generic command line interface: The last argument should evaluate to a javaScript object which will be used as source for extending the default behavior. Any javaScript will be supported:

npm run build '{module:{preprocessor:{javaScript:{loader:"babel"}}}}'

If you're using weboptimizer in a toolchain were none printable or none unicode compatible symbols should be used (for example content which should replace placeholder) you can encode your javaScript expression as base64 code:

npm run build '{module:{preprocessor:{ejs:{locals:{name:'häns'}}}}}'

# is the same as:

npm run build 'e21vZHVsZTp7cHJlcHJvY2Vzc29yOntwdWc6e2xvY2Fsczp7bmFtZTonaMOkbnMnfX19fX0='

There is a static tool clientnode and helper instance provided to each evaluation or execution context within the package.json (see the API-Documentation, link above, for more details):

...
"webOptimizer": {
    ...
    "libraryName": {"__evaluate__": indicator.isPlainObject(self.name) ? helper.stripLoader(self.request) : 'random'},
    ...
},
...

WebStorm

Eslint

  1. Set eslint package to project specific one: /PATH/TO/PROJECT/node_modules/eslint
  2. Set Working directory: /PATH/TO/PROJECT
  3. Set configuration file path: /PATH/TO/PROJECT/node_modules/weboptimizer/dist/eslint.config.js

About this website

Provider ofhttps://tsickert.com/weboptimizer:
Torben Sickert
Waldstraße 29
791194 Gundelfingen i.Br.
Phone: +49 (0) 176 / 10 248 185
Email:
[email protected]
Website: https://tsickert.com
homedeDE: StartseitefrFR: Maison

Disclaimer

Liability for content

The content of our pages has been prepared with the utmost care. However, we cannot guarantee the accuracy, completeness or timeliness of the content. As a service provider, we are responsible for our own content on these pages under general law. However, we are not obliged to monitor transmitted or stored third-party information or investigate circumstances that indicate illegal activity. Obligations to remove or block the use of information under general law remain unaffected. Liability in this respect is only possible from the time we become aware of a specific infringement. Upon becoming aware of any such legal violations, we will remove this content immediately.

Liability for links

Our website contains links to external third-party websites whose content is beyond our control. We therefore cannot accept any responsibility for such third-party content. The respective provider or operator of each linked site is always responsible for its content. The linked sites were checked for possible legal violations when the links were created. No illegal content was apparent at that time. However, continuous monitoring of linked sites is not reasonable without specific evidence of a legal violation. If we become aware of any legal violations, we will remove the relevant links immediately.

Copyright

Content and works on these pages created by the site operators are subject to German copyright law. Reproduction, adaptation, distribution and any use beyond the scope of copyright law require the written consent of the respective author or creator. Downloads and copies of this site are permitted for private, non-commercial use only. Where content on this site was not created by the operator, third-party copyrights are respected. In particular, third-party content is identified as such. If you become aware of a copyright infringement, please notify us. Upon becoming aware of any legal violations, we will remove the relevant content immediately.

Privacy Policy

You can generally use our website without providing personal data. Where personal data (such as names, addresses or email addresses) is collected on our pages, this is, wherever possible, always done on a voluntary basis. This data will not be passed on to third parties without your express consent. Please note that data transmission over the internet (for example, when communicating by email) may have security vulnerabilities. It is not possible to completely protect data against access by third parties. We expressly object to the use by third parties of contact details published to meet legal notice requirements for sending unsolicited advertising or information. The site operators expressly reserve the right to take legal action if unsolicited advertising, such as spam emails, is sent.

Content Delivery Network (Cloudflare)

We use Cloudflare (Cloudflare, Inc., 101 Townsend St., San Francisco, CA 94107, USA) to protect and speed up our website. This constitutes a legitimate interest within the meaning of Art. 6(1)(f) GDPR. Cloudflare processes log data (including IP addresses) and sets technically necessary cookies to defend against malicious bot traffic. We have concluded a Data Processing Addendum (DPA) with Cloudflare based on the EU Standard Contractual Clauses. Cloudflare is certified under the EU-U.S. Data Privacy Framework.

Privacy Statement for using Google Analytics

This website uses Google Analytics 4, a web analytics service provided by Google Ireland Limited ("Google", Gordon House, Barrow Street, Dublin 4, Ireland). Data is processed solely on the basis of your express consent (Art. 6(1)(a) GDPR). Google Analytics uses cookies that enable analysis of how you use the website. Information generated by these cookies about your use of this website is transmitted to and stored on a Google server; transfer of data to third countries (such as the United States) cannot be ruled out. IP anonymization is enabled by default on this website, so Google truncates your IP address within a member state of the European Union or another state party to the Agreement on the European Economic Area before transmission. You may withdraw your consent at any time with effect for the future through the cookie settings (our consent tool), or prevent data collection by using the official Google browser add-on .

Copyright Statement

Unless noted otherwise, all artwork on this website is protected property of the website author. Any use for commercial purpose, reproduction and publication requires the author's written permission. Commercial work created in cooperation or bound by contract with third parties are specifically marked. Respective copyrights apply.

top