🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

express-webpack-assets

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-webpack-assets

Middleware for Express.js to load webpack assets

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
1.8K
1%
Maintainers
1
Weekly downloads
 
Created
Source

express-webpack-asset

js-standard-style

Middleware to load hashed webpack assets, in combination with https://github.com/kossnocorp/assets-webpack-plugin

Configuration

Example webpack config:

var SaveHashes = require('assets-webpack-plugin');

plugins: [
  new SaveHashes({path: path.join(__dirname, 'config')})
],
entry: './main.js',

output: {
  path: path.join(__dirname, '.tmp', 'public', 'app'),
  filename: "bundle-[name]-[hash].js",
  publicPath: "/app/"
},

Express config:

var webpackAssets = require('express-webpack-assets');
app.use(webpackAssets('./config/webpack-assets.json', {
	devMode: true/false
}));

Express-webpack-asset can also support you with multiple json files. For that case you need to pass a path of your assets json files, example of usage:

var webpackAssets = require('express-webpack-assets');
app.use(webpackAssets('./config', {
	devMode: true/false
}));

Please bear in mind that result of extend will override the object properties with equal names w.r.t. order returned by Nodejs.fs.readDir.

Options

{
	devMode: boolean // Enables development mode which disables caching of the manifest, which is useful when the manifest changes rapidly
}

Usage

Example webpack-assets.json (taken from the README in the assets-webpack-plugin project):

{
    "one": {
        "js": "/js/one_2bb80372ebe8047a68d4.bundle.js"
    },
    "two": {
        "js": "/js/two_2bb80372ebe8047a68d4.bundle.js"
    }
}

Two ways of linking in assets. Examples shown linking 'one' asset using express EJS view snippets.

<script src="<%= webpack_asset('one', 'js') %>"></script>

<script src="<%= webpack_asset('one').js %>"></script>

FAQs

Package last updated on 11 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts