@financial-times/dotcom-build-images 11.2.1 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/index.js +13 -15
- package/dist/tsconfig.tsbuildinfo +1 -2805
- package/package.json +4 -11
- package/src/__test__/index.spec.ts +8 -2
- package/src/index.ts +13 -15
package/dist/node/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PageKitImagesPlugin = void 0;
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const glob = require('glob');
|
|
6
|
-
const
|
|
6
|
+
const EntryPlugin = require('webpack/lib/EntryPlugin');
|
|
7
7
|
class PageKitImagesPlugin {
|
|
8
8
|
constructor(options = {}) {
|
|
9
9
|
this.options = {
|
|
@@ -16,24 +16,22 @@ class PageKitImagesPlugin {
|
|
|
16
16
|
absolute: true,
|
|
17
17
|
cwd: path.resolve(this.options.basePath)
|
|
18
18
|
});
|
|
19
|
-
|
|
19
|
+
for (const imageFile of imageFiles) {
|
|
20
|
+
new EntryPlugin(compiler.context, imageFile, '__images__').apply(compiler);
|
|
21
|
+
}
|
|
20
22
|
const isDevMode = compiler.options.mode === 'development';
|
|
21
|
-
const outputFileName = isDevMode ? '[name]
|
|
23
|
+
const outputFileName = isDevMode ? '[name][ext]' : '[name].[contenthash:12][ext]';
|
|
22
24
|
compiler.options.module.rules.push({
|
|
23
25
|
test: /\.(png|jpe?g|gif|webp|ico|svg)$/,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// retain relative directory structure
|
|
32
|
-
return path.join(relativePath, outputFileName);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
26
|
+
type: 'asset/resource',
|
|
27
|
+
generator: {
|
|
28
|
+
filename: (pathInfo) => {
|
|
29
|
+
const dirname = path.dirname(pathInfo.module.resource);
|
|
30
|
+
const relativePath = path.relative(this.options.basePath, dirname);
|
|
31
|
+
// retain relative directory structure
|
|
32
|
+
return path.join(relativePath, outputFileName);
|
|
35
33
|
}
|
|
36
|
-
|
|
34
|
+
}
|
|
37
35
|
});
|
|
38
36
|
}
|
|
39
37
|
}
|