Skip to content

Commit 13b5481

Browse files
authored
Merge pull request #133 from mzgoddard/defaults-tweak
Tune default options
2 parents 4997f2f + 6b5cf0d commit 13b5481

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

.travis.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
language: node_js
22
node_js:
3-
- "6"
4-
- "5"
3+
- "7"
54
- "4"
65

76
env:
87
matrix:
9-
- WEBPACK_VERSION=1.13.1 EXTRACT_TEXT_VERSION=1
10-
- WEBPACK_VERSION=2.2.1 EXTRACT_TEXT_VERSION=2.0.0
8+
- WEBPACK_VERSION=1 EXTRACT_TEXT_VERSION=1
9+
- WEBPACK_VERSION=2 EXTRACT_TEXT_VERSION=2
1110
matrix:
1211
fast_finish: true
1312
allow_failures:
1413
- node_js: "4"
15-
env: WEBPACK_VERSION=2.2.1 EXTRACT_TEXT_VERSION=2.0.0
14+
env: WEBPACK_VERSION=2 EXTRACT_TEXT_VERSION=2
1615
before_script:
1716
- npm rm webpack extract-text-webpack-plugin
1817
- npm install webpack@$WEBPACK_VERSION extract-text-webpack-plugin@$EXTRACT_TEXT_VERSION
1918
cache:
2019
directories:
21-
- node_modules
20+
- node_modules

index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ function serializeHashContent(module) {
249249
// };
250250

251251
function HardSourceWebpackPlugin(options) {
252-
this.options = options;
252+
this.options = options || {};
253253
}
254254

255255
HardSourceWebpackPlugin.prototype.getPath = function(dirName, suffix) {
@@ -280,7 +280,11 @@ HardSourceWebpackPlugin.prototype.apply = function(compiler) {
280280
logger.lock();
281281

282282
if (!options.cacheDirectory) {
283-
options.cacheDirectory = 'node_modules/.cache/hard-source/[confighash]';
283+
options.cacheDirectory = path.resolve(
284+
process.cwd(),
285+
compiler.options.context,
286+
'node_modules/.cache/hard-source/[confighash]'
287+
);
284288
}
285289

286290
this.compilerOutputOptions = compiler.options.output;
@@ -395,8 +399,8 @@ HardSourceWebpackPlugin.prototype.apply = function(compiler) {
395399
!compiler.options.recordsInputPath &&
396400
!compiler.options.recordsPath
397401
) {
398-
compiler.options.recordsInputPath =
399-
this.getPath('node_modules/.cache/hard-source/[confighash]/records.json');
402+
options.recordsInputPath = path.join(options.cacheDirectory, 'records.json');
403+
compiler.options.recordsInputPath = this.getPath(options.recordsInputPath);
400404
}
401405
if (options.recordsOutputPath || options.recordsPath) {
402406
if (compiler.options.recordsOutputPath || compiler.options.recordsPath) {
@@ -421,8 +425,9 @@ HardSourceWebpackPlugin.prototype.apply = function(compiler) {
421425
!compiler.options.recordsOutputPath &&
422426
!compiler.options.recordsPath
423427
) {
428+
options.recordsOutputPath = path.join(options.cacheDirectory, 'records.json');
424429
compiler.options.recordsOutputPath =
425-
this.getPath('node_modules/.cache/hard-source/[confighash]/records.json');
430+
this.getPath(options.recordsOutputPath);
426431
}
427432

428433
var cacheDirPath = this.getCachePath();

0 commit comments

Comments
 (0)