mirror of
https://github.com/modernweb-dev/rocket.git
synced 2026-03-21 15:54:57 +00:00
Compare commits
2 Commits
@rocket/cl
...
@rocket/cl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb07267289 | ||
|
|
738941afdd |
@@ -107,3 +107,23 @@ export default ({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
<!-- prettier-ignore-end -->
|
<!-- prettier-ignore-end -->
|
||||||
|
|
||||||
|
## Advanced
|
||||||
|
|
||||||
|
Sometimes you need even more control over the build process. In these cases you can take full control over the rollup config.
|
||||||
|
|
||||||
|
For example if you wanna add an `acron` plugin to rollup
|
||||||
|
|
||||||
|
<!-- prettier-ignore-start -->
|
||||||
|
```js
|
||||||
|
import { importAssertions } from 'acorn-import-assertions';
|
||||||
|
|
||||||
|
/** @type {import('rocket/cli').RocketCliConfig} */
|
||||||
|
export default ({
|
||||||
|
rollup: config => ({
|
||||||
|
...config,
|
||||||
|
acornInjectPlugins: [importAssertions],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
```
|
||||||
|
<!-- prettier-ignore-end -->
|
||||||
|
|||||||
@@ -1,5 +1,23 @@
|
|||||||
# @rocket/cli
|
# @rocket/cli
|
||||||
|
|
||||||
|
## 0.9.10
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 738941a: In `rocket.config.js` you can now supply a rollup config function.
|
||||||
|
|
||||||
|
```js
|
||||||
|
export default {
|
||||||
|
rollup: config => {
|
||||||
|
// config will be the fully generated config object after all presets have been applied
|
||||||
|
if (config.plugins.includes('...')) {
|
||||||
|
// change some config options
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
## 0.9.9
|
## 0.9.9
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/cli",
|
"name": "@rocket/cli",
|
||||||
"version": "0.9.9",
|
"version": "0.9.10",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ async function productionBuild(config) {
|
|||||||
...config.setupBuildPlugins,
|
...config.setupBuildPlugins,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
const finalConfig = typeof config.rollup === 'function' ? config.rollup(mpaConfig) : mpaConfig;
|
||||||
await buildAndWrite(mpaConfig);
|
await buildAndWrite(finalConfig);
|
||||||
|
|
||||||
const serviceWorkerSourcePath = path.resolve('docs/_merged_assets/service-worker.js');
|
const serviceWorkerSourcePath = path.resolve('docs/_merged_assets/service-worker.js');
|
||||||
if (fs.existsSync(serviceWorkerSourcePath)) {
|
if (fs.existsSync(serviceWorkerSourcePath)) {
|
||||||
|
|||||||
@@ -188,4 +188,23 @@ describe('RocketCli e2e', () => {
|
|||||||
errorMatch: /Found 1 missing reference targets/,
|
errorMatch: /Found 1 missing reference targets/,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can completely take over the rollup config', async () => {
|
||||||
|
cli = await executeBuild('e2e-fixtures/rollup-override/rocket.config.js');
|
||||||
|
|
||||||
|
const indexHtml = await readBuildOutput(cli, 'index.html', {
|
||||||
|
stripToBody: true,
|
||||||
|
formatHtml: true,
|
||||||
|
});
|
||||||
|
expect(indexHtml).to.equal(
|
||||||
|
[
|
||||||
|
'<h1 id="importing-foo">',
|
||||||
|
' <a aria-hidden="true" tabindex="-1" href="#importing-foo"><span class="icon icon-link"></span></a',
|
||||||
|
' >Importing foo',
|
||||||
|
'</h1>',
|
||||||
|
'',
|
||||||
|
'<script type="module" src="./7338509a.js" mdjs-setup=""></script>',
|
||||||
|
].join('\n'),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
**/*.njk
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
layout: layout-raw
|
||||||
|
---
|
||||||
|
|
||||||
|
# Importing foo
|
||||||
|
|
||||||
|
```js script
|
||||||
|
import { foo } from './not-foo.js';
|
||||||
|
|
||||||
|
console.log(foo);
|
||||||
|
```
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export const notFoo = 'not-foo';
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// @ts-no-check
|
||||||
|
|
||||||
|
/** @type {Partial<import("../../../types/main").RocketCliOptions>} */
|
||||||
|
const config = {
|
||||||
|
rollup: config => ({
|
||||||
|
...config,
|
||||||
|
shimMissingExports: true,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
1
packages/cli/types/main.d.ts
vendored
1
packages/cli/types/main.d.ts
vendored
@@ -40,6 +40,7 @@ export interface RocketCliOptions extends Pick<RocketPreset, PresetKeys> {
|
|||||||
start?: RocketStartConfig;
|
start?: RocketStartConfig;
|
||||||
|
|
||||||
// advanced
|
// advanced
|
||||||
|
rollup?: (config: any) => void; // TODO: improve
|
||||||
devServer?: DevServerConfig;
|
devServer?: DevServerConfig;
|
||||||
eleventy?: (eleventyConfig: any) => void; // TODO: improve
|
eleventy?: (eleventyConfig: any) => void; // TODO: improve
|
||||||
plugins?: RocketPlugin[];
|
plugins?: RocketPlugin[];
|
||||||
|
|||||||
Reference in New Issue
Block a user