assets-webpack-plugin
Advanced tools
Comparing version 3.6.2 to 3.6.3
@@ -13,2 +13,8 @@ # Change Log | ||
## 3.6.3 - 2018-06-13 | ||
### Changed | ||
- Add support for multiple files of the same extension (kudos to [@aaronatmycujoo](https://github.com/aaronatmycujoo) see [#79](https://github.com/kossnocorp/assets-webpack-plugin/pull/79) and [@Kronuz](https://github.com/Kronuz) see [#64](https://github.com/kossnocorp/assets-webpack-plugin/pull/64)) | ||
## 3.6.2 - 2018-06-13 | ||
@@ -15,0 +21,0 @@ |
20
index.js
@@ -18,3 +18,4 @@ var fs = require('fs') | ||
update: false, | ||
fullPath: true | ||
fullPath: true, | ||
arrayOfPaths: false | ||
}, options) | ||
@@ -67,3 +68,12 @@ this.writer = createQueuedWriter(createOutputWriter(this.options)) | ||
var typeName = getAssetKind(options, asset) | ||
typeMap[typeName] = !!assetPath ? `${assetPath}/${asset}`.replace(/\/\//, '/') : asset | ||
var combinedPath = assetPath ? `${assetPath}/${asset}`.replace(/\/\//, '/') : asset | ||
var type = typeof typeMap[typeName] | ||
if (type === 'undefined') { | ||
typeMap[typeName] = combinedPath | ||
} else { | ||
if (type === 'string') { | ||
typeMap[typeName] = [typeMap[typeName]] | ||
} | ||
typeMap[typeName].push(combinedPath) | ||
} | ||
@@ -80,3 +90,7 @@ return typeMap | ||
if (manifestEntry) { | ||
var manifestAssetKey = manifestEntry.js.substr(assetPath.length) | ||
var js = manifestEntry.js | ||
if (!Array.isArray(js)) { | ||
js = [js] | ||
} | ||
var manifestAssetKey = js[js.length - 1].substr(assetPath.length) | ||
var parentSource = compilation.assets[manifestAssetKey] | ||
@@ -83,0 +97,0 @@ var entryText = parentSource.source() |
{ | ||
"name": "assets-webpack-plugin", | ||
"version": "3.6.2", | ||
"version": "3.6.3", | ||
"description": "Emits a json file with assets paths", | ||
@@ -31,2 +31,3 @@ "main": "index.js", | ||
"lodash": "^3.9.3", | ||
"mini-css-extract-plugin": "^0.4.0", | ||
"mocha": "^5.2.0", | ||
@@ -37,3 +38,3 @@ "rimraf": "^2.6.2", | ||
"style-loader": "^0.21.0", | ||
"webpack": "^4.8.3" | ||
"webpack": "^4.10.2" | ||
}, | ||
@@ -40,0 +41,0 @@ "dependencies": { |
@@ -1,1 +0,2 @@ | ||
require('./stylesheet.css') | ||
require('./stylesheet1.css') | ||
require('./stylesheet2.css') |
@@ -9,2 +9,3 @@ /* eslint-env mocha */ | ||
var expectOutput = require('./utils/expectOutput')(OUTPUT_DIR) | ||
var MiniCssExtractPlugin = require('mini-css-extract-plugin') | ||
@@ -53,3 +54,3 @@ describe('Plugin', function () { | ||
}, | ||
plugins: [new Plugin({path: 'tmp'})] | ||
plugins: [new Plugin({ path: 'tmp' })] | ||
} | ||
@@ -110,3 +111,3 @@ | ||
}, | ||
plugins: [new Plugin({path: 'tmp'})] | ||
plugins: [new Plugin({ path: 'tmp' })] | ||
} | ||
@@ -135,3 +136,3 @@ | ||
}, | ||
plugins: [new Plugin({path: 'tmp'})] | ||
plugins: [new Plugin({ path: 'tmp' })] | ||
} | ||
@@ -156,3 +157,3 @@ | ||
}, | ||
plugins: [new Plugin({path: 'tmp'})] | ||
plugins: [new Plugin({ path: 'tmp' })] | ||
} | ||
@@ -170,2 +171,63 @@ | ||
it('works with ExtractTextPlugin for multiple stylesheets', function (done) { | ||
var extractTextPlugin1 = new MiniCssExtractPlugin({filename: '[name]-bundle1.css', chunkFilename: '[id].css'}) | ||
var extractTextPlugin2 = new MiniCssExtractPlugin({filename: '[name]-bundle2.css', chunkFilename: '[id].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: { | ||
rules: [ | ||
{ | ||
test: /1\.css$/, | ||
use: [ | ||
MiniCssExtractPlugin.loader, | ||
'css-loader' | ||
] | ||
}, | ||
{ | ||
test: /2\.css$/, | ||
use: [ | ||
MiniCssExtractPlugin.loader, | ||
'css-loader' | ||
] | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
extractTextPlugin1, | ||
extractTextPlugin2, | ||
new Plugin({ | ||
path: 'tmp' | ||
}) | ||
] | ||
} | ||
var expected = { | ||
one: { | ||
js: 'one-bundle.js' | ||
}, | ||
two: { | ||
js: 'two-bundle.js' | ||
}, | ||
styles: { | ||
js: 'styles-bundle.js', | ||
css: ['styles-bundle1.css', 'styles-bundle2.css'] | ||
} | ||
} | ||
var args = { | ||
config: webpackConfig, | ||
expected: expected | ||
} | ||
expectOutput(args, done) | ||
}) | ||
it('includes full publicPath', function (done) { | ||
@@ -179,3 +241,3 @@ var webpackConfig = { | ||
}, | ||
plugins: [new Plugin({path: 'tmp'})] | ||
plugins: [new Plugin({ path: 'tmp' })] | ||
} | ||
@@ -182,0 +244,0 @@ |
Sorry, the diff of this file is not supported yet
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
50466
36
1019
10