mirror of
https://github.com/modernweb-dev/rocket.git
synced 2026-03-21 08:51:18 +00:00
Compare commits
2 Commits
@rocket/la
...
@rocket/cl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb07267289 | ||
|
|
738941afdd |
@@ -107,3 +107,23 @@ export default ({
|
||||
});
|
||||
```
|
||||
<!-- 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
|
||||
|
||||
## 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
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rocket/cli",
|
||||
"version": "0.9.9",
|
||||
"version": "0.9.10",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
|
||||
@@ -54,8 +54,8 @@ async function productionBuild(config) {
|
||||
...config.setupBuildPlugins,
|
||||
],
|
||||
});
|
||||
|
||||
await buildAndWrite(mpaConfig);
|
||||
const finalConfig = typeof config.rollup === 'function' ? config.rollup(mpaConfig) : mpaConfig;
|
||||
await buildAndWrite(finalConfig);
|
||||
|
||||
const serviceWorkerSourcePath = path.resolve('docs/_merged_assets/service-worker.js');
|
||||
if (fs.existsSync(serviceWorkerSourcePath)) {
|
||||
|
||||
@@ -188,4 +188,23 @@ describe('RocketCli e2e', () => {
|
||||
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;
|
||||
|
||||
// advanced
|
||||
rollup?: (config: any) => void; // TODO: improve
|
||||
devServer?: DevServerConfig;
|
||||
eleventy?: (eleventyConfig: any) => void; // TODO: improve
|
||||
plugins?: RocketPlugin[];
|
||||
|
||||
Reference in New Issue
Block a user