Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

attach-version-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attach-version-webpack-plugin

attach-version-webpack-plugin

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

attach-version-webpack-plugin

attach-version-webpack-plugin is webpack plugin for inject asset version in template files.

Install

npm i --D attach-version-webpack-plugin

Basic usage

webpack.config.js

const AttachVersionWebpackPlugin = require('attach-version-webpack-plugin');

module.exports = {
  entry: 'index.js',
  output: {
    path: 'path/to/dist',
    filename: 'index.bundle.js'
  },
  plugins: [
    new AttachVersionWebpackPlugin({
        context: 'path/to' // The base directory, an absolute path, for resolving entry points.
        templates: [
            'index.html' // The template directory, an relative path via context path.
            ...
        ]
    }),
  ]
}

The contents of generated index.html file.

Template files move through declared webpack output path.

if online, injected remote asset version.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    ...
    <!-- css asset -->
    <link rel="stylesheet" href="path/to/test.css?v=07798350">
    ...
    <!-- remote javascript asset -->
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react-router/4.2.0/react-router.min.js?v=59eb182b"></script>
</head>
<body>
    <!-- internal javascript asset -->
	<script type="text/javascript" src="common_bundle.js?v=747ec249"></script>
	...
</body>
</html>

Options

NameTypeDefaultDescription
context{String}''The base directory, an absolute path, for resolving entry points.

context: '/src'
templates: ['index.html'] // /src/index.html
templates{Array}'[]'The template directory, an relative path via context path.

Context example

context: '/src'
templates: ['index.html'] // /src/index.html

Keywords

webpack

FAQs

Package last updated on 30 Mar 2018

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