@imtf/profile-scripts 1.0.4 → 1.0.5
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/changelog.md +36 -0
- package/package.json +4 -4
- package/scripts/svgPlugin.mjs +40 -0
package/changelog.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Versions
|
|
2
|
+
|
|
3
|
+
Here you can find a resume of all changes between versions.
|
|
4
|
+
|
|
5
|
+
## 1.0.5
|
|
6
|
+
|
|
7
|
+
### Bug fixes
|
|
8
|
+
|
|
9
|
+
- Npm package issues fixed.
|
|
10
|
+
|
|
11
|
+
## 1.0.4
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- Use differents loaders for svgs :
|
|
16
|
+
* Svgs part of /src except ones that are in /src/assets will be
|
|
17
|
+
loaded as React components with svgr.
|
|
18
|
+
* Others will be loaded as dataurl (base64)
|
|
19
|
+
|
|
20
|
+
## 1.0.3
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
- Load fonts (.ttf, .eot) and images (.gif, .svg) within js file as data-urls
|
|
25
|
+
|
|
26
|
+
## 1.0.2
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
- Load fonts (.woff, .woff2) and images (.jpg, .png) within js file as data-urls
|
|
31
|
+
|
|
32
|
+
## 1.0.1
|
|
33
|
+
|
|
34
|
+
### Bug fixes
|
|
35
|
+
|
|
36
|
+
- Moved some dependencies from devDepenencies to dependencies.
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtf/profile-scripts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Default scripts to bundle & transpile imtf front-end plugins",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"profile-scripts": "./bin/profile-scripts.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
10
|
+
"bin/",
|
|
11
|
+
"scripts/",
|
|
12
|
+
"changelog.md"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "NODE_ENV=production node scripts/esbuild.mjs",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { transform } from '@svgr/core'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
|
|
5
|
+
const svgPlugin = (options = {}) => ({
|
|
6
|
+
name: 'svgr',
|
|
7
|
+
setup(build) {
|
|
8
|
+
build.onLoad({ filter: /\.svg$/ }, async args => {
|
|
9
|
+
// Read file content
|
|
10
|
+
const svg = await fs.promises.readFile(args.path, 'utf8')
|
|
11
|
+
|
|
12
|
+
// Determine relative path
|
|
13
|
+
const relativePath = path.relative(process.cwd(), args.path)
|
|
14
|
+
|
|
15
|
+
// This is an asset ==> dataurl
|
|
16
|
+
if (
|
|
17
|
+
!relativePath.startsWith('src/') ||
|
|
18
|
+
relativePath.startsWith('src/assets/')
|
|
19
|
+
) {
|
|
20
|
+
return {
|
|
21
|
+
contents: svg,
|
|
22
|
+
loader: 'dataurl',
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Otherwise it's a react component
|
|
27
|
+
const contents = await transform(
|
|
28
|
+
svg,
|
|
29
|
+
{ ...options },
|
|
30
|
+
{ filePath: args.path }
|
|
31
|
+
)
|
|
32
|
+
return {
|
|
33
|
+
contents,
|
|
34
|
+
loader: 'jsx',
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export default svgPlugin
|