Socket
Socket
Sign inDemoInstall

assets-webpack-plugin

Package Overview
Dependencies
6
Maintainers
2
Versions
75
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.5.1 to 4.0.0

6

CHANGELOG.md

@@ -13,2 +13,8 @@ # Change Log

## 4.0.0 - 2018-05-29
### Changed
- webpack 4 support (kudos to [@ztoben](https://github.com/ztoben) and [@saveman71](https://github.com/saveman71) see [#89](https://github.com/kossnocorp/assets-webpack-plugin/pull/89))
## 3.5.1 - 2017-01-20

@@ -15,0 +21,0 @@

30

index.js

@@ -28,3 +28,3 @@ var merge = require('lodash.merge')

compiler.plugin('after-emit', function (compilation, callback) {
var afterEmit = (compilation, callback) => {
var options = compiler.options

@@ -41,13 +41,13 @@ var stats = compilation.getStats().toJson({

})
// publicPath with resolved [hash] placeholder
// publicPath with resolved [hash] placeholder
var assetPath = (stats.publicPath && self.options.fullPath) ? stats.publicPath : ''
// assetsByChunkName contains a hash with the bundle names and the produced files
// e.g. { one: 'one-bundle.js', two: 'two-bundle.js' }
// in some cases (when using a plugin or source maps) it might contain an array of produced files
// e.g. {
// main:
// [ 'index-bundle-42b6e1ec4fa8c5f0303e.js',
// 'index-bundle-42b6e1ec4fa8c5f0303e.js.map' ]
// }
// assetsByChunkName contains a hash with the bundle names and the produced files
// e.g. { one: 'one-bundle.js', two: 'two-bundle.js' }
// in some cases (when using a plugin or source maps) it might contain an array of produced files
// e.g. {
// main:
// [ 'index-bundle-42b6e1ec4fa8c5f0303e.js',
// 'index-bundle-42b6e1ec4fa8c5f0303e.js.map' ]
// }
var assetsByChunkName = stats.assetsByChunkName

@@ -99,3 +99,11 @@

})
})
}
if (compiler.hooks) {
var plugin = {name: 'AssetsWebpackPlugin'}
compiler.hooks.afterEmit.tapAsync(plugin, afterEmit)
} else {
compiler.plugin('after-emit', afterEmit)
}
}

@@ -102,0 +110,0 @@ }

@@ -28,3 +28,3 @@ /**

if (empty) {
// start processing
// start processing
processor(data, iterator(callback))

@@ -31,0 +31,0 @@ }

@@ -6,10 +6,10 @@ var escapeRegExp = require('escape-string-regexp')

var template_cache = Object.create(null)
var templateCache = Object.create(null)
module.exports = function createTemplate (str) {
if (!template_cache[str]) {
template_cache[str] = new PathTemplate(str)
if (!templateCache[str]) {
templateCache[str] = new PathTemplate(str)
}
return template_cache[str]
return templateCache[str]
}

@@ -142,5 +142,2 @@

switch (field.placeholder) {
case 'id':
pattern += '\\d+'
break
case 'hash':

@@ -151,2 +148,3 @@ case 'chunkhash':

break
case 'id':
case 'name':

@@ -153,0 +151,0 @@ case 'file':

{
"name": "assets-webpack-plugin",
"version": "3.5.1",
"version": "4.0.0",
"description": "Emits a json file with assets paths",

@@ -28,20 +28,19 @@ "main": "index.js",

"devDependencies": {
"chai": "^3.0.0",
"css-loader": "^0.9.1",
"extract-text-webpack-plugin": "^0.3.8",
"chai": "^4.1.2",
"css-loader": "^0.28.11",
"lodash": "^3.9.3",
"mocha": "^2.2.5",
"rimraf": "^2.2.8",
"snazzy": "^3.0.0",
"standard": "^6.0.8",
"style-loader": "^0.8.3",
"webpack": "^1.3.3-beta1"
"mocha": "^5.2.0",
"rimraf": "^2.6.2",
"snazzy": "^7.1.1",
"standard": "^11.0.1",
"style-loader": "^0.21.0",
"webpack": "^4.8.3"
},
"dependencies": {
"camelcase": "^1.2.1",
"camelcase": "^5.0.0",
"escape-string-regexp": "^1.0.3",
"lodash.assign": "^3.2.0",
"lodash.merge": "^3.3.2",
"lodash.assign": "^4.2.0",
"lodash.merge": "^4.6.1",
"mkdirp": "^0.5.1"
}
}
/* eslint-env mocha */
var path = require('path')
var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var rmRf = require('rimraf')
var Plugin = require('../index.js')
var manifestStr = require('./fixtures/manifest.js')

@@ -168,47 +165,2 @@ var OUTPUT_DIR = path.join(__dirname, '../tmp')

it('works with ExtractTextPlugin for stylesheets', function (done) {
var webpackConfig = {
entry: {
one: path.join(__dirname, 'fixtures/one.js'),
two: path.join(__dirname, 'fixtures/two.js'),
styles: path.join(__dirname, 'fixtures/styles.js')
},
output: {
path: OUTPUT_DIR,
filename: '[name]-bundle.js'
},
module: {
loaders: [
{test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader')}
]
},
plugins: [
new ExtractTextPlugin('[name]-bundle.css', {allChunks: true}),
new Plugin({
path: 'tmp'
})
]
}
var expected = {
one: {
js: 'one-bundle.js'
},
two: {
js: 'two-bundle.js'
},
styles: {
js: 'styles-bundle.js',
css: 'styles-bundle.css'
}
}
var args = {
config: webpackConfig,
expected: expected
}
expectOutput(args, done)
})
it('includes full publicPath', function (done) {

@@ -265,32 +217,2 @@ var webpackConfig = {

it('works with CommonChunksPlugin', function (done) {
var webpackConfig = {
entry: {
one: path.join(__dirname, 'fixtures/common-chunks/one.js'),
two: path.join(__dirname, 'fixtures/common-chunks/two.js')
},
output: {
path: OUTPUT_DIR,
filename: '[name].js'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({name: 'common'}),
new Plugin({path: 'tmp'})
]
}
var expected = {
one: {js: 'one.js'},
two: {js: 'two.js'},
common: {js: 'common.js'}
}
var args = {
config: webpackConfig,
expected: expected
}
expectOutput(args, done)
})
it('allows injection of metadata', function (done) {

@@ -330,105 +252,2 @@ var webpackConfig = {

})
it('works with default includeManifest', function (done) {
var webpackConfig = {
entry: {
one: path.join(__dirname, 'fixtures/common-chunks/one.js'),
two: path.join(__dirname, 'fixtures/common-chunks/two.js')
},
output: {
path: OUTPUT_DIR,
filename: '[name].js'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({names: ['common', 'manifest']}),
new Plugin({path: 'tmp', includeManifest: true})
]
}
var expected = {
one: {js: 'one.js'},
two: {js: 'two.js'},
common: {js: 'common.js'},
manifest: {
js: 'manifest.js',
text: manifestStr
}
}
var args = {
config: webpackConfig,
expected: expected
}
expectOutput(args, done)
})
it('works with custom includeManifest', function (done) {
var webpackConfig = {
entry: {
one: path.join(__dirname, 'fixtures/common-chunks/one.js'),
two: path.join(__dirname, 'fixtures/common-chunks/two.js')
},
output: {
path: OUTPUT_DIR,
filename: '[name].js'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({names: ['common', 'manifesto']}),
new Plugin({path: 'tmp', includeManifest: 'manifesto'})
]
}
var expected = {
one: {js: 'one.js'},
two: {js: 'two.js'},
common: {js: 'common.js'},
manifesto: {
js: 'manifesto.js',
text: manifestStr
}
}
var args = {
config: webpackConfig,
expected: expected
}
expectOutput(args, done)
})
it('supports source maps with includeManifest', function (done) {
var webpackConfig = {
devtool: 'sourcemap',
entry: {
one: path.join(__dirname, 'fixtures/common-chunks/one.js'),
two: path.join(__dirname, 'fixtures/common-chunks/two.js')
},
output: {
path: OUTPUT_DIR,
filename: '[name].js'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({names: ['common', 'manifesto']}),
new Plugin({path: 'tmp', includeManifest: 'manifesto'})
]
}
var expected = {
one: {js: 'one.js'},
two: {js: 'two.js'},
common: {js: 'common.js'},
manifesto: {
js: 'manifesto.js',
text: require('./fixtures/manifestWithSourceMap')
}
}
var args = {
config: webpackConfig,
expected: expected
}
expectOutput(args, done)
})
})
/* eslint-env mocha */
/* eslint-disable no-unused-expressions */

@@ -62,3 +63,3 @@ var path = require('path')

it('updates output between compiler calls when options.update is true', function (done) {
var config_1 = {
var config1 = {
entry: {

@@ -73,3 +74,3 @@ one: path.join(__dirname, 'fixtures/one.js')

}
var config_2 = {
var config2 = {
entry: {

@@ -86,5 +87,5 @@ two: path.join(__dirname, 'fixtures/two.js')

var expected = {one: {js: 'one-bundle.js'}, two: {js: 'two-bundle.js'}}
var args = {config: config_2, expected: expected}
var args = {config: config2, expected: expected}
webpack(config_1, function (err, stats) {
webpack(config1, function (err, stats) {
expect(err).to.be.null

@@ -97,3 +98,3 @@ expect(stats.hasErrors()).to.be.false

it('overwrites output between compiler calls when options.update is false', function (done) {
var config_1 = {
var config1 = {
entry: {

@@ -108,3 +109,3 @@ one: path.join(__dirname, 'fixtures/one.js')

}
var config_2 = {
var config2 = {
entry: {

@@ -121,5 +122,5 @@ two: path.join(__dirname, 'fixtures/two.js')

var expected = {two: {js: 'two-bundle.js'}}
var args = {config: config_2, expected: expected}
var args = {config: config2, expected: expected}
webpack(config_1, function (err, stats) {
webpack(config1, function (err, stats) {
expect(err).to.be.null

@@ -126,0 +127,0 @@ expect(stats.hasErrors()).to.be.false

@@ -69,3 +69,3 @@ /* eslint-env mocha */

expect(tpl.matches('foo-bar.666.js')).to.eq(true)
expect(tpl.matches('foo-bar.nope.js')).to.eq(false)
expect(tpl.matches('foo-bar.chunk.js')).to.eq(true)
})

@@ -72,0 +72,0 @@

@@ -0,1 +1,3 @@

/* eslint-disable no-unused-expressions */
var _ = require('lodash')

@@ -2,0 +4,0 @@ var expect = require('chai').expect

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc