Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

assets-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assets-webpack-plugin - npm Package Compare versions

Comparing version 2.2.3 to 2.3.0

lib/getFileExtension.js

124

index.js

@@ -1,42 +0,102 @@

var buildOutput = require('./lib/buildOutput');
var writeOutput = require('./lib/writeOutput');
var mkdirp = require('mkdirp');
var path = require('path');
var mkdirp = require('mkdirp');
var path = require('path');
var fs = require('fs');
function Plugin(options) {
this.options = options || {};
var getAssetKind = require('./lib/getAssetKind');
var isHMRUpdate = require('./lib/isHMRUpdate');
function AssetsWebpackPlugin (options) {
this.options = this.getOptions(options || {});
this.outputPath = path.join(this.options.path, this.options.filename);
}
Plugin.prototype.apply = function(compiler) {
var _this = this;
// var assets = {};
AssetsWebpackPlugin.prototype = {
constructor: AssetsWebpackPlugin,
compiler.plugin('emit', function(compiler, callback) {
// console.log('emit');
// console.log(assets);
var outputDir = _this.options.path || '.';
getOptions: function (options) {
var defaults = {
path: '.',
filename: 'webpack-assets.json',
prettyPrint: false
};
return Object.keys(defaults).reduce(function (map, option) {
map[option] = options.hasOwnProperty(option) ? options[option] : defaults[option];
return map;
}, {});
},
try {
// make sure output folder exists
mkdirp.sync(outputDir);
} catch (e) {
compiler.errors.push(new Error(
'Assets Plugin: Could not create output folder' + outputDir
));
return callback();
}
apply: function (compiler) {
var self = this;
var output = buildOutput(compiler);
var outputFilename = _this.options.filename || 'webpack-assets.json';
var outputFullPath = path.join(outputDir, outputFilename);
compiler.plugin("emit", function (compilation, callback) {
var options = compiler.options;
stats = compilation.getStats().toJson({
hash: true,
publicPath: true,
assets: true,
chunks: false,
modules: false,
source: false,
errorDetails: false,
timings: false
});
// publicPath with resolved [hash] placeholder
var publicPath = 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' ]
// }
var assetsByChunkName = stats.assetsByChunkName;
// if (_this.options.multiCompiler) {
// output = extend(assets, output);
// }
writeOutput(compiler, output, outputFullPath);
var output = Object.keys(assetsByChunkName).reduce(function (chunkMap, chunkName) {
var assets = assetsByChunkName[chunkName];
if (!Array.isArray(assets)) {
assets = [assets];
}
chunkMap[chunkName] = assets.reduce(function (typeMap, asset) {
if (isHMRUpdate(options, asset)) {
return typeMap;
}
callback();
});
var typeName = getAssetKind(options, asset);
typeMap[typeName] = publicPath + asset;
return typeMap;
}, {});
return chunkMap;
}, {});
self.writeOutput(output, compilation);
callback();
});
},
writeOutput: function (assets, compiler) {
try {
mkdirp.sync(this.options.path);
} catch (e) {
compiler.errors.push(new Error(
'[AssetsWebpackPlugin]: Could not create output folder' + this.options.path
));
return;
}
var json = JSON.stringify(assets, null, this.options.prettyPrint ? 2 : null);
fs.writeFile(this.outputPath, json, function (err) {
if (err) {
compiler.errors.push(new Error(
'[AssetsWebpackPlugin]: Unable to write to ' + this.outputPath
));
}
});
},
};
module.exports = Plugin;
module.exports = AssetsWebpackPlugin;

@@ -1,18 +0,17 @@

var getFileExt = require('./getFileExt');
var camelcase = require('camelcase');
var isSourceMap = require('./isSourceMap');
var getFileExtension = require('./getFileExtension');
function getAssetKind(compilerOptions, asset) {
// console.log('compilerOptions', compilerOptions);
// console.log(asset);
var ext = getFileExt(compilerOptions, asset);
var isSM = isSourceMap(compilerOptions, asset);
if (isSM) {
return ext + 'Map';
} else {
return ext;
}
module.exports = function getAssetKind (options, asset) {
var isMap = isSourceMap(options, asset);
if (isMap) {
asset = asset.replace(/\.(?:source[ _.-]?)?map/i, '');
}
var ext = getFileExtension(asset);
if (isMap) {
ext += 'SourceMap';
}
return camelcase(ext);
};
module.exports = getAssetKind;

@@ -1,10 +0,7 @@

var getMapSegment = require('./getMapSegment');
var pathTemplate = require('./pathTemplate');
function isSourceMap(compilerOptions, asset) {
var mapSegment = getMapSegment(compilerOptions);
var mapRegex = new RegExp(mapSegment);
return mapRegex.test(asset);
module.exports = function isSourceMap (options, asset) {
var sourceMapFilename = options.output.sourceMapFilename;
var sourcemapTemplate = pathTemplate(sourceMapFilename);
return sourcemapTemplate.matches(asset);
};
module.exports = isSourceMap;
{
"name": "assets-webpack-plugin",
"version": "2.2.3",
"version": "2.3.0",
"description": "Emits a json file with assets paths",

@@ -38,4 +38,6 @@ "main": "index.js",

"dependencies": {
"camelcase": "^1.2.1",
"escape-string-regexp": "^1.0.3",
"mkdirp": "^0.5.1"
}
}

@@ -12,20 +12,53 @@ assets-webpack-plugin

This plug-in outputs a json file with the generated assets so you can find the assets from somewhere else.
This plug-in outputs a json file with the paths of the generated assets so you can find them from somewhere else.
### Example output:
As of version 2.0 the output now includes keys for different assets kinds.
The output is a JSON object in the form:
```json
{
"bundle_name": {
"asset_kind": "/public/path/to/asset"
}
}
```
Where:
* `"bundle_name"` is the name of the bundle (the key of the entry object in your webpack config, or "main" if your entry is an array).
* `"asset_kind"` is the camel-cased file extension of the asset, except for source maps where `asset_kind = camelcase(file_xtension) + 'SourceMap'`.
For example, given the following webpack config:
```js
{
"one": {
"js": "one-bundle.js",
"jsMap": "one-bundle.js.map"
},
"two": {
"js": "two-bundle.js"
}
entry: {
one: ['src/one.js'],
two: ['src/two.js']
},
output: {
path: path.join(__dirname, "public", "js"),
publicPath: "/js/",
filename: '[name]_[hash].bundle.js',
sourceMapFilename: '[file].map'
}
}
```
The plugin will output the following json file:
```json
{
"one": {
"js": "/js/one_2bb80372ebe8047a68d4.bundle.js",
"jsSourceMap": "/js/one_2bb80372ebe8047a68d4.bundle.js.map"
},
"two": {
"js": "/js/two_2bb80372ebe8047a68d4.bundle.js",
"jsSourceMap": "/js/two_2bb80372ebe8047a68d4.bundle.js.map"
}
}
```
## Install

@@ -42,16 +75,16 @@

```js
var path = require('path');
var AssetsPlugin = require('assets-webpack-plugin');
var path = require('path');
var AssetsPlugin = require('assets-webpack-plugin');
var assetsPluginInstance = new AssetsPlugin();
module.exports = {
...
output: {
path: path.join(__dirname, "public", "js"),
filename: "[name]-bundle-[hash].js",
publicPath: "/js/"
},
....
plugins: [assetsPluginInstance]
};
// ...
output: {
path: path.join(__dirname, "public", "js"),
filename: "[name]-bundle-[hash].js",
publicPath: "/js/"
},
// ....
plugins: [assetsPluginInstance]
};
```

@@ -63,6 +96,4 @@

__path__:
__path__: Path where to save the created json file. Defaults to the current directory.
Path where to save the created json file. Defaults to the current directory.
```js

@@ -72,6 +103,4 @@ new AssetsPlugin({path: path.join(__dirname, 'app', 'views')})

__filename__:
__filename__: Name for the created json file. Defaults to `webpack-assets.json`
Name for the created json file. Defaults to `webpack-assets.json`
```js

@@ -81,2 +110,9 @@ new AssetsPlugin({filename: 'assets.json'})

__prettyPrint__: Whether to format the json output for readability. Defaults to false.
```js
new AssetsPlugin({prettyPrint: true})
```
### Using this with Rails

@@ -83,0 +119,0 @@

@@ -1,52 +0,66 @@

var webpack = require('webpack');
var getAssetKind = require('../lib/getAssetKind.js');
var chai = require('chai');
var expect = chai.expect;
var webpack = require('webpack');
var getAssetKind = require('../lib/getAssetKind.js');
var chai = require('chai');
var expect = chai.expect;
describe('getAssetKind', function() {
var webpackConfig;
var webpackConfig;
beforeEach(function () {
webpackConfig = {
output: {
filename: '[name].js?[hash]',
sourceMapFilename: '[file].map[query]'
},
devtool: 'sourcemap'
};
});
beforeEach(function () {
webpackConfig = {
output: {
filename: '[name].js?[hash]',
sourceMapFilename: '[file].map[query]'
},
devtool: 'sourcemap'
};
});
describe('js', function() {
describe('js', function() {
it('returns js', function () {
var input = 'desktop.js';
var res = getAssetKind(webpackConfig, input);
expect(res).to.eq('js');
});
it('returns js', function () {
var input = 'desktop.js';
var res = getAssetKind(webpackConfig, input);
expect(res).to.eq('js');
});
it('returns js with hash', function() {
var input = 'desktop.js?9b913c8594ce98e06b21';
var res = getAssetKind(webpackConfig, input);
expect(res).to.eq('js');
});
it('returns js with hash', function() {
var input = 'desktop.js?9b913c8594ce98e06b21';
var res = getAssetKind(webpackConfig, input);
expect(res).to.eq('js');
});
});
});
describe('map', function() {
describe('map', function() {
it('returns map', function() {
var input = 'desktop.js.map';
var res = getAssetKind(webpackConfig, input);
expect(res).to.eq('jsMap');
});
it('returns map', function() {
var input = 'desktop.js.map';
var res = getAssetKind(webpackConfig, input);
expect(res).to.eq('jsSourceMap');
});
it('returns map', function() {
var input = 'desktop.js.map?9b913c8594ce98e06b21';
var res = getAssetKind(webpackConfig, input);
expect(res).to.eq('jsMap');
});
it('returns map', function() {
var input = 'desktop.js.map?9b913c8594ce98e06b21';
var res = getAssetKind(webpackConfig, input);
expect(res).to.eq('jsSourceMap');
});
});
it('detects sourcemap even without extension', function() {
webpackConfig = {
output: {
filename: '[name].js?[hash]',
sourceMapFilename: 'srcmap_[hash]_[file][query]'
},
devtool: 'sourcemap'
};
var input = 'srcmap_9b913c8594ce98e06b21_desktop.js?9b913c8594ce98e06b21';
var res = getAssetKind(webpackConfig, input);
expect(res).to.eq('jsSourceMap');
});
});
});

@@ -1,43 +0,25 @@

var getFileExt = require('../lib/getFileExt.js');
var chai = require('chai');
var expect = chai.expect;
var getFileExtension = require('../lib/getFileExtension');
var chai = require('chai');
var expect = chai.expect;
function expectExtension(webpackConfig, file, expected) {
var actual = getFileExt(webpackConfig, file) ;
expect(actual).to.eq(expected);
function expectExtension(fileName, expected) {
var actual = getFileExtension(fileName) ;
expect(actual).to.eq(expected);
}
describe('getFileExt', function() {
var webpackConfig;
var webpackConfig;
beforeEach(function () {
webpackConfig = {
output: {
filename: '[name].js?[hash]',
sourceMapFilename: '[file].map[query]'
},
devtool: 'sourcemap'
};
});
it('returns the right extension with simple file names', function() {
expectExtension('main.js', 'js');
expectExtension('main-9b913c8594ce98e06b21.js', 'js');
});
it('is js', function() {
webpackConfig.output.filename = '[name].js';
expectExtension(webpackConfig, 'main.js', 'js');
});
it('returns the right extension with query strings', function() {
expectExtension('main.js?9b913c8594ce98e06b21', 'js');
expectExtension('desktop.js.map?9b913c8594ce98e06b21', 'map');
});
it('is js with hash', function() {
webpackConfig.output.filename = '[name]-[hash].js';
expectExtension(webpackConfig, 'main-9b913c8594ce98e06b21.js', 'js');
});
it('is js with hash', function() {
webpackConfig.output.filename = '[name].js?[hash]';
expectExtension(webpackConfig, 'main.js?9b913c8594ce98e06b21', 'js');
});
it('is js', function() {
webpackConfig.output.filename = '[name].js';
expectExtension(webpackConfig, 'desktop.js.map?9b913c8594ce98e06b21', 'js');
});
});
/*jshint expr: true*/
var path = require('path');
var fs = require('fs');
// var mocha = require('mocha');
var chai = require('chai');
var webpack = require('webpack');
var path = require('path');
var fs = require('fs');
// var mocha = require('mocha');
var chai = require('chai');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var rm_rf = require('rimraf');
var mkdirp = require('mkdirp');
var _ = require('lodash');
var Plugin = require('../index.js');
var expect = chai.expect;
var rm_rf = require('rimraf');
var mkdirp = require('mkdirp');
var _ = require('lodash');
var Plugin = require('../index.js');
var expect = chai.expect;
var OUTPUT_DIR = path.join(__dirname, '../tmp');
function expectOutput(args, done) {
if (!args.config) throw new Error('Expected args.config');
if (!args.expected) throw new Error('Expected args.expected');
if (!done) throw new Error('Expected done');
if (!args.config) {
throw new Error('Expected args.config');
}
if (!args.expected) {
throw new Error('Expected args.expected');
}
if (!done) {
throw new Error('Expected done');
}
var webpackConfig = args.config;
var expectedResult = args.expected;
var outputFile = args.outputFile;
var webpackConfig = args.config;
var expectedResult = args.expected;
var outputFile = args.outputFile;
// Create output folder
mkdirp(OUTPUT_DIR, function(err) {
expect(err).to.be.null;
// Create output folder
mkdirp(OUTPUT_DIR, function(err) {
expect(err).to.be.null;
outputFile = outputFile || 'webpack-assets.json';
outputFile = outputFile || 'webpack-assets.json';
webpack(webpackConfig, function(err, stats) {
expect(err).to.be.null;
expect(stats.hasErrors()).to.be.false;
webpack(webpackConfig, function(err, stats) {
expect(err).to.be.null;
expect(stats.hasErrors()).to.be.false;
var content = fs.readFileSync(path.join(OUTPUT_DIR, outputFile)).toString();
var content = fs.readFileSync(path.join(OUTPUT_DIR, outputFile)).toString();
if (_.isRegExp(expectedResult)) {
expect(content).to.match(expectedResult);
} else if(_.isString(expectedResult)) {
expect(content).to.contain(expectedResult);
} else {
// JSON object provided
var actual = JSON.parse(content);
expect(actual).to.eql(expectedResult);
}
if (_.isRegExp(expectedResult)) {
expect(content).to.match(expectedResult);
} else if(_.isString(expectedResult)) {
expect(content).to.contain(expectedResult);
} else {
// JSON object provided
var actual = JSON.parse(content);
expect(actual).to.eql(expectedResult);
}
done();
});
done();
});
});
});
}
describe('Plugin', function() {
beforeEach(function(done) {
rm_rf(OUTPUT_DIR, done);
});
it('generates a default file for a single entry point', function(done) {
var webpackConfig = {
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
filename: 'index-bundle.js'
},
plugins: [new Plugin({
path: 'tmp'
})]
};
beforeEach(function(done) {
rm_rf(OUTPUT_DIR, done);
});
var expected = {
main: {
js: 'index-bundle.js'
}
};
expected = JSON.stringify(expected);
it('generates a default file for a single entry point', function(done) {
var webpackConfig = {
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
filename: 'index-bundle.js'
},
plugins: [new Plugin({
path: 'tmp'
})]
};
var args = {
config: webpackConfig,
expected: expected
};
var expected = {
main: {
js: 'index-bundle.js'
}
};
expected = JSON.stringify(expected);
expectOutput(args, done);
});
var args = {
config: webpackConfig,
expected: expected
};
it('generates a default file with multiple entry points', function(done) {
var webpackConfig = {
entry: {
one: path.join(__dirname, 'fixtures/one.js'),
two: path.join(__dirname, 'fixtures/two.js')
},
output: {
path: OUTPUT_DIR,
filename: '[name]-bundle.js'
},
plugins: [new Plugin({
path: 'tmp'
})]
};
expectOutput(args, done);
});
var expected = {
one: {
js: 'one-bundle.js'
},
two: {
js: 'two-bundle.js'
}
};
it('generates a default file with multiple entry points', function(done) {
var webpackConfig = {
entry: {
one: path.join(__dirname, 'fixtures/one.js'),
two: path.join(__dirname, 'fixtures/two.js')
},
output: {
path: OUTPUT_DIR,
filename: '[name]-bundle.js'
},
plugins: [new Plugin({path: 'tmp'})]
};
var args = {
config: webpackConfig,
expected: expected
};
var expected = {
one: {
js: 'one-bundle.js'
},
two: {
js: 'two-bundle.js'
}
};
expectOutput(args, done);
});
var args = {
config: webpackConfig,
expected: expected
};
it('allows you to specify your own filename', function(done) {
expectOutput(args, done);
});
var webpackConfig = {
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
filename: 'index-bundle.js'
},
plugins: [new Plugin({
filename: 'foo.json',
path: 'tmp'
})]
};
it('allows you to specify your own filename', function(done) {
var expected = {
main: {
js: 'index-bundle.js'
}
};
var webpackConfig = {
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
filename: 'index-bundle.js'
},
plugins: [new Plugin({
filename: 'foo.json',
path: 'tmp'
})]
};
var args = {
config: webpackConfig,
expected: expected,
outputFile: 'foo.json'
};
var expected = {
main: {
js: 'index-bundle.js'
}
};
expectOutput(args, done);
});
var args = {
config: webpackConfig,
expected: expected,
outputFile: 'foo.json'
};
it('works with source maps', function(done) {
expectOutput(args, done);
});
var webpackConfig = {
devtool: 'sourcemap',
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
filename: 'index-bundle.js'
},
plugins: [new Plugin({
path: 'tmp'
})]
};
it('works with source maps', function(done) {
var expected = {
main: {
js: 'index-bundle.js',
jsMap: 'index-bundle.js.map'
}
};
var webpackConfig = {
devtool: 'sourcemap',
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
filename: 'index-bundle.js'
},
plugins: [new Plugin({path: 'tmp'})]
};
var args = {
config: webpackConfig,
expected: expected
};
var expected = {
main: {
js: 'index-bundle.js',
jsSourceMap: 'index-bundle.js.map'
}
};
expectOutput(args, done);
});
var args = {
config: webpackConfig,
expected: expected
};
it('works with source maps and hash', function(done) {
var webpackConfig = {
devtool: 'sourcemap',
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
filename: 'index-bundle-[hash].js'
},
plugins: [new Plugin({
path: 'tmp'
})]
};
expectOutput(args, done);
});
var expected = /{"main":{"js":"index-bundle-[0-9a-f]+\.js","jsMap":"index-bundle-[0-9a-f]+\.js\.map"}}/;
it('works with source maps and hash', function(done) {
var webpackConfig = {
devtool: 'sourcemap',
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
filename: 'index-bundle-[hash].js'
},
plugins: [new Plugin({path: 'tmp'})]
};
var args = {
config: webpackConfig,
expected: expected
};
var expected = /{"main":{"js":"index-bundle-[0-9a-f]+\.js","jsSourceMap":"index-bundle-[0-9a-f]+\.js\.map"}}/;
expectOutput(args, done);
});
var args = {
config: webpackConfig,
expected: expected
};
it('handles hashes in bundle filenames', function(done) {
expectOutput(args, done);
});
var webpackConfig = {
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
filename: 'index-bundle-[hash].js'
},
plugins: [new Plugin({
path: 'tmp'
})]
};
it('handles hashes in bundle filenames', function(done) {
var expected = /{"main":{"js":"index-bundle-[0-9a-f]+\.js"}}/;
var webpackConfig = {
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
filename: 'index-bundle-[hash].js'
},
plugins: [new Plugin({path: 'tmp'})]
};
var args = {
config: webpackConfig,
expected: expected
};
var expected = /{"main":{"js":"index-bundle-[0-9a-f]+\.js"}}/;
expectOutput(args, done);
});
var args = {
config: webpackConfig,
expected: expected
};
it('handles hashes in a different position', function(done) {
expectOutput(args, done);
});
var webpackConfig = {
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
filename: '[name].js?[hash]'
},
plugins: [new Plugin({
path: 'tmp'
})]
};
it('handles hashes in a different position', function(done) {
var expected = /{"main":{"js":"main\.js\?[0-9a-f]+"}}/;
var webpackConfig = {
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
filename: '[name].js?[hash]'
},
plugins: [new Plugin({path: 'tmp'})]
};
var args = {
config: webpackConfig,
expected: expected
};
var expected = /{"main":{"js":"main\.js\?[0-9a-f]+"}}/;
expectOutput(args, done);
});
var args = {
config: webpackConfig,
expected: expected
};
it('works with ExtractTextPlugin for stylesheets', function(done) {
expectOutput(args, 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'
})
]
};
it('works with ExtractTextPlugin for stylesheets', function(done) {
var expected = {
one: {
js: "one-bundle.js"
},
two: {
js: "two-bundle.js"
},
styles: {
js: "styles-bundle.js",
css: "styles-bundle.css"
}
};
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 args = {
config: webpackConfig,
expected: expected
};
var expected = {
one: {
js: "one-bundle.js"
},
two: {
js: "two-bundle.js"
},
styles: {
js: "styles-bundle.js",
css: "styles-bundle.css"
}
};
expectOutput(args, done);
});
var args = {
config: webpackConfig,
expected: expected
};
it.skip('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: 'tmp'
})]
},
{
entry: {
two: path.join(__dirname, 'fixtures/two.js')
},
output: {
path: OUTPUT_DIR,
filename: 'two-bundle.js'
},
plugins: [new Plugin({
multiCompiler: true,
path: 'tmp'
})]
}
];
expectOutput(args, done);
});
var expected = {
one: {
js: "one-bundle.js"
},
two: {
js: "two-bundle.js"
}
};
it.skip('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: 'tmp'
})]
},
{
entry: {
two: path.join(__dirname, 'fixtures/two.js')
},
output: {
path: OUTPUT_DIR,
filename: 'two-bundle.js'
},
plugins: [new Plugin({
multiCompiler: true,
path: 'tmp'
})]
}
];
var args = {
config: webpackConfig,
expected: expected
};
var expected = {
one: {
js: "one-bundle.js"
},
two: {
js: "two-bundle.js"
}
};
expectOutput(args, done);
});
var args = {
config: webpackConfig,
expected: expected
};
it('includes full publicPath', function(done) {
expectOutput(args, done);
});
var webpackConfig = {
devtool: 'sourcemap',
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
publicPath: '/public/path/',
filename: 'index-bundle.js'
},
plugins: [new Plugin({
path: 'tmp'
})]
};
it('includes full publicPath', function(done) {
var expected = {
main: {
js: '/public/path/index-bundle.js',
jsMap: '/public/path/index-bundle.js.map'
}
};
var webpackConfig = {
entry: path.join(__dirname, 'fixtures/one.js'),
output: {
path: OUTPUT_DIR,
publicPath: '/public/path/[hash]/',
filename: 'index-bundle.js'
},
plugins: [new Plugin({path: 'tmp'})]
};
var args = {
config: webpackConfig,
expected: expected
};
var expected = new RegExp('/public/path/[0-9a-f]+/index-bundle.js', 'i');
expectOutput(args, done);
});
var args = {
config: webpackConfig,
expected: expected
};
expectOutput(args, done);
});
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);
});
});
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc