Skip to content

Commit 25b857d

Browse files
committed
init
1 parent aa22ee9 commit 25b857d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3241
-2
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
dist

CHANGELOG.md

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# @web/rollup-plugin-import-meta-assets
2+
3+
## 2.2.1
4+
5+
### Patch Changes
6+
7+
- 1c0088de: Update Rollup to version 4.
8+
9+
## 2.2.0
10+
11+
### Minor Changes
12+
13+
- c185cbaa: Set minimum node version to 18
14+
15+
## 2.1.0
16+
17+
### Minor Changes
18+
19+
- a8039a46: Enabled using dynamic import vars when importing assets
20+
21+
## 2.0.2
22+
23+
### Patch Changes
24+
25+
- db02e2df: Make import-meta-assets rollup plugin ignore patterns like "new URL('./', import.meta.url)" that reference directories.
26+
27+
## 2.0.1
28+
29+
### Patch Changes
30+
31+
- f64cc232: Allow import-meta-assets rollup plugin to bundle meta assets that use backticks, but do not contain any dynamic expressions inside the template literal.
32+
33+
## 2.0.0
34+
35+
### Major Changes
36+
37+
- febd9d9d: Set node 16 as the minimum version.
38+
- 72c63bc5: Require [email protected] and update all Rollup related dependencies to latest.
39+
40+
## 1.0.8
41+
42+
### Patch Changes
43+
44+
- 1113fa09: Update `@rollup/pluginutils`
45+
46+
## 1.0.7
47+
48+
### Patch Changes
49+
50+
- d3448166: Allow ignoring assets during transformation
51+
52+
## 1.0.6
53+
54+
### Patch Changes
55+
56+
- b77e5d16: fix(rollup-plugin-import-meta-assets): skip unnecessary sourcemap generation
57+
58+
## 1.0.5
59+
60+
### Patch Changes
61+
62+
- 7fd7a799: fix(rollup-plugin-import-meta-assets): fix outputted sourcemaps
63+
64+
## 1.0.4
65+
66+
### Patch Changes
67+
68+
- 5bb5dd0: fix type reference
69+
70+
## 1.0.3
71+
72+
### Patch Changes
73+
74+
- 279f756: ---
75+
76+
fix warn() code when error was caught
77+
78+
## 1.0.2
79+
80+
### Patch Changes
81+
82+
- 68e24b6: publish correct entrypoint
83+
84+
## 1.0.1
85+
86+
### Patch Changes
87+
88+
- fd9fe56: publish files
89+
90+
## 1.0.0
91+
92+
### Major Changes
93+
94+
- 401e225: First release

README.md

+60-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,60 @@
1-
# package-template
2-
A template for Modern Web packages
1+
# Rollup Plugin import-meta-assets
2+
3+
Rollup plugin that detects assets references relative to modules using patterns such as `new URL('./assets/my-img.png', import.meta.url)`.
4+
5+
The referenced assets are added to the rollup pipeline, allowing them to be transformed and hash the filenames.
6+
7+
## How it works
8+
9+
A common pattern is to import an asset to get the URL of it after bundling:
10+
11+
```js
12+
import myImg from './assets/my-img.png';
13+
```
14+
15+
This doesn't work in the browser without transformation. This plugin makes it possible to use an identical pattern using `import.meta.url` which does work in the browser:
16+
17+
```js
18+
const myImg = new URL('./assets/my-img.png', import.meta.url);
19+
```
20+
21+
### Dynamic variables
22+
23+
You can also use dynamic variables like so:
24+
25+
```js
26+
const myImg = new URL(`./assets/${myImg}.png`, import.meta.url);
27+
```
28+
29+
Please consult the [dynamic-import-vars plugin](https://github.com/rollup/plugins/blob/master/packages/dynamic-import-vars) documentation for options and limitations.
30+
31+
## Install
32+
33+
Using npm:
34+
35+
```
36+
npm install @web/rollup-plugin-import-meta-assets --save-dev
37+
```
38+
39+
## Usage
40+
41+
Create a rollup.config.js [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:
42+
43+
```js
44+
import { importMetaAssets } from '@web/rollup-plugin-import-meta-assets';
45+
46+
export default {
47+
input: 'src/index.js',
48+
output: {
49+
dir: 'output',
50+
format: 'es',
51+
},
52+
plugins: [importMetaAssets()],
53+
};
54+
```
55+
56+
Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).
57+
58+
## Documentation
59+
60+
See [our website](https://modern-web.dev/docs/building/rollup-plugin-import-meta-assets/) for full documentation.

index.mjs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import cjsEntrypoint from './src/rollup-plugin-import-meta-assets.js';
2+
3+
const { importMetaAssets } = cjsEntrypoint;
4+
5+
export { importMetaAssets };

0 commit comments

Comments
 (0)