Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lightapis/rollup-plugin-html-location
Specify the output location of the html entry file
https://github.com/lightapis/rollup-plugin-html-location
html location plugin rollup rollup-plugin
Last synced: 7 days ago
JSON representation
Specify the output location of the html entry file
- Host: GitHub
- URL: https://github.com/lightapis/rollup-plugin-html-location
- Owner: LightAPIs
- License: mit
- Created: 2023-10-26T15:47:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-29T11:57:30.000Z (about 1 year ago)
- Last Synced: 2024-10-07T08:46:53.741Z (about 1 month ago)
- Topics: html, location, plugin, rollup, rollup-plugin
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/rollup-plugin-html-location
- Size: 37.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rollup-plugin-html-location
Specify the output location of the html entry file.
## Installation
```shell
npm install rollup-plugin-html-location -D
```## Usage
Assuming the project structure is as follows:
```
/
├─src
│ ├─demo
│ │ ├─demo1
│ │ │ └─index.html
│ │ └─demo2
│ │ └─index.html
│ └─main.js
├─package.json
├─rollup.config.js
└─...
```### When without plugin
```javascript
// rollup.config.js
export default {
input: {
demo1: 'src/demo1/index.html',
demo2: 'src/demo2/index.html',
main: 'main.js',
},
output: {
dir: 'dist',
entryFileNames: '[name].js',
},
};
```**Output:**
```
├─dist
│ ├─src
│ │ ├─demo1
│ │ │ └─index.html
│ │ └─demo2
│ │ └─index.html
│ └─main.js
└─...
```### With plugin
#### `dir` option
```javascript
// rollup.config.js
import HTMLLocation from 'rollup-plugin-html-location';export default {
input: {
demo1: 'src/demo1/index.html',
demo2: 'src/demo2/index.html',
main: 'main.js',
},
output: {
dir: 'dist',
entryFileNames: '[name].js',
},
plugins: [
HTMLLocation({
dir: 'result',
}),
],
};
```**Output:**
```
├─dist
│ ├─result
│ │ └─src
│ │ ├─demo1
│ │ │ └─index.html
│ │ └─demo2
│ │ └─index.html
│ └─main.js
└─...
```#### `filename` option
##### Use path key value pair
```javascript
// rollup.config.js
import HTMLLocation from 'rollup-plugin-html-location';export default {
input: {
demo1: 'src/demo1/index.html',
demo2: 'src/demo2/index.html',
main: 'main.js',
},
output: {
dir: 'dist',
entryFileNames: '[name].js',
},
plugins: [
HTMLLocation({
filename: {
'src/demo1/index.html': 'result/demo1.html'
'src/demo2/index.html': 'result/demo2.html'
}
})
],
};
```**Output:**
```
├─dist
│ ├─result
│ │ ├─demo1.html
│ │ └─demo2.html
│ └─main.js
└─...
```##### Use function
```javascript
// rollup.config.js
import HTMLLocation from 'rollup-plugin-html-location';export default {
input: {
demo1: 'src/demo1/index.html',
demo2: 'src/demo2/index.html',
main: 'main.js',
},
output: {
dir: 'dist',
entryFileNames: '[name].js',
},
plugins: [
HTMLLocation({
filename: input => input.replace('src/', ''),
}),
],
};
```**Output:**
```
├─dist
│ ├─demo1
│ │ └─index.html
│ ├─demo2
│ │ └─index.html
│ └─main.js
└─...
```#### `disableClearEmptyFolder` option
```javascript
// rollup.config.js
import HTMLLocation from 'rollup-plugin-html-location';export default {
input: {
demo1: 'src/demo1/index.html',
demo2: 'src/demo2/index.html',
main: 'main.js',
},
output: {
dir: 'dist',
entryFileNames: '[name].js',
},
plugins: [
HTMLLocation({
filename: {
'src/demo1/index.html': 'demo1.html'
'src/demo2/index.html': 'demo2.html'
},
disableClearEmptyFolder: true,
}),
],
};
```**Output:**
```
├─dist
│ ├─src
│ │ ├─demo1
│ │ └─demo2
│ ├─demo1.html
│ ├─demo2.html
│ └─main.js
└─...
```#### `logging` option
```javascript
// rollup.config.js
import HTMLLocation from 'rollup-plugin-html-location';export default {
input: {
demo1: 'src/demo1/index.html',
demo2: 'src/demo2/index.html',
main: 'main.js',
},
output: {
dir: 'dist',
entryFileNames: '[name].js',
},
plugins: [
HTMLLocation({
filename: {
'src/demo1/index.html': 'demo1.html'
'src/demo2/index.html': 'demo2.html'
},
logging: true,
}),
],
};
```Print operation log:
```shell
html-location: [src/demo1/index.html] ==> [demo1.html]
html-location: [src/demo2/index.html] ==> [demo2.html]
html-location: clear empty folder!
```## License
[MIT](./LICENSE)