assets-webpack-plugin
Advanced tools
Comparing version 0.3.0 to 0.3.1
20
index.js
var fs = require('fs'); | ||
var path = require('path'); | ||
var assets = {}; | ||
function extend(target, source) { | ||
for(var k in source){ | ||
target[k] = source[k]; | ||
} | ||
return target; | ||
} | ||
function Plugin(options) { | ||
@@ -25,3 +34,3 @@ this.options = options || {}; | ||
var outputFull = path.join(outputDir, outputFilename); | ||
self.writeOutput(compiler, hashes, outputFull); | ||
self.writeOutput(compiler, self.options.multiCompiler ? extend(assets,hashes) : hashes, outputFull); | ||
callback(); | ||
@@ -85,6 +94,10 @@ }); | ||
.replace('[query]', '') | ||
.replace('[hash]', '') | ||
.replace('.', ''); | ||
.replace('[hash]', ''); | ||
// mapSegment e.g. ".map" | ||
var mapRegex = new RegExp(mapSegment); | ||
// value e.g. | ||
// desktop.js.map | ||
// desktop.js.map?9b913c8594ce98e06b21 | ||
function isSourceMap(value) { | ||
@@ -107,3 +120,2 @@ return mapRegex.test(value); | ||
// e.g. [ 'styles-bundle.js', 'styles-bundle.css' ] | ||
return stringOrArray | ||
@@ -110,0 +122,0 @@ .filter(isAsset) |
{ | ||
"name": "assets-webpack-plugin", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Emits a json file with assets paths", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,3 +29,5 @@ var path = require('path'); | ||
} else { | ||
expect(content).toContain(expectedResult); | ||
var json = JSON.parse(content); | ||
var expectedJson = JSON.parse(expectedResult); | ||
expect(json).toEqual(expectedJson); | ||
} | ||
@@ -106,2 +108,37 @@ } | ||
it('generates a default file with multiple compilers', function(done) { | ||
var webpackConfig = [ | ||
{ | ||
entry: { | ||
one: path.join(__dirname, 'fixtures/one.js') | ||
}, | ||
output: { | ||
path: OUTPUT_DIR, | ||
filename: 'one-bundle.js' | ||
}, | ||
plugins: [new Plugin({ | ||
multiCompiler: true, | ||
path: 'dist' | ||
})] | ||
}, | ||
{ | ||
entry: { | ||
two: path.join(__dirname, 'fixtures/two.js') | ||
}, | ||
output: { | ||
path: OUTPUT_DIR, | ||
filename: 'two-bundle.js' | ||
}, | ||
plugins: [new Plugin({ | ||
multiCompiler: true, | ||
path: 'dist' | ||
})] | ||
} | ||
]; | ||
var expected = ['{"one":"one-bundle.js","two":"two-bundle.js"}']; | ||
testPlugin(webpackConfig, expected, null, done); | ||
}); | ||
it('allows you to specify your own filename', function(done) { | ||
@@ -108,0 +145,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12499
328