Compare commits

...

6 Commits

Author SHA1 Message Date
github-actions[bot]
579ecfde50 Version Packages 2021-01-07 09:10:15 +01:00
Mathieu Puech
9aa3265ebb docs: small fixes on CONTRIBUTING.md 2021-01-07 08:54:17 +01:00
Mathieu Puech
d955b436b6 fix(drawer): reset translation on teardown overlay controller 2021-01-07 08:54:17 +01:00
Thomas Allmer
3468ff9fc2 fix(cli): rollup-plugin-html needs to be aware of the pathPrefix 2021-01-07 08:49:40 +01:00
github-actions[bot]
fd4bc27f16 Version Packages 2021-01-06 00:49:41 +01:00
Thomas Allmer
641c7e551c feat: add pathPrefix option for subfolder deployment 2021-01-06 00:46:39 +01:00
23 changed files with 135 additions and 86 deletions

View File

@@ -15,7 +15,7 @@ git clone git@github.com:modernweb-dev/rocket.git
Once cloning is complete, change directory to the repo. Once cloning is complete, change directory to the repo.
```sh ```sh
cd web cd rocket
``` ```
Now add your fork as a remote Now add your fork as a remote
@@ -89,7 +89,7 @@ Exceptions:
## Committing Your Changes ## Committing Your Changes
Commit messages must follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0-beta.2/) Commit messages must follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/)
Modern-web uses package name as scope. So for example if you fix a _terrible bug_ in the package `@web/test-runner`, the commit message should look like this: Modern-web uses package name as scope. So for example if you fix a _terrible bug_ in the package `@web/test-runner`, the commit message should look like this:
```sh ```sh

View File

@@ -9,11 +9,8 @@ import { rocketLaunch } from '@rocket/launch';
export default { export default {
presets: [rocketLaunch()], presets: [rocketLaunch()],
build: { emptyOutputDir: true,
emptyOutputDir: true, pathPrefix: 'subfolder-only-for-build',
pathPrefix: 'subfolder-only-for-build',
serviceWorkerFileName: 'service-worker.js',
},
}; };
``` ```

View File

@@ -12,7 +12,6 @@ import { absoluteBaseUrlNetlify } from '@rocket/core/helpers';
export default /** @type {Partial<import('@rocket/cli').RocketCliOptions>} */ ({ export default /** @type {Partial<import('@rocket/cli').RocketCliOptions>} */ ({
presets: [rocketLaunch(), rocketBlog(), rocketSearch()], presets: [rocketLaunch(), rocketBlog(), rocketSearch()],
emptyOutputDir: false,
absoluteBaseUrl: absoluteBaseUrlNetlify('http://localhost:8080'), absoluteBaseUrl: absoluteBaseUrlNetlify('http://localhost:8080'),
}); });
``` ```

View File

@@ -1,6 +1,13 @@
# @rocket/building-rollup # @rocket/building-rollup
## 0.1.1
### Patch Changes
- 3468ff9: Update rollup-plugin-html to support `absolutePathPrefix` option
## 0.1.0 ## 0.1.0
### Minor Changes ### Minor Changes
- 1971f5d: Initial Release - 1971f5d: Initial Release

View File

@@ -1,6 +1,6 @@
{ {
"name": "@rocket/building-rollup", "name": "@rocket/building-rollup",
"version": "0.1.0", "version": "0.1.1",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -54,7 +54,7 @@
"@babel/preset-env": "^7.12.11", "@babel/preset-env": "^7.12.11",
"@rollup/plugin-babel": "^5.2.2", "@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-node-resolve": "^11.0.1", "@rollup/plugin-node-resolve": "^11.0.1",
"@web/rollup-plugin-html": "^1.3.3", "@web/rollup-plugin-html": "^1.4.0",
"@web/rollup-plugin-import-meta-assets": "^1.0.4", "@web/rollup-plugin-import-meta-assets": "^1.0.4",
"@web/rollup-plugin-polyfills-loader": "^1.0.3", "@web/rollup-plugin-polyfills-loader": "^1.0.3",
"browserslist": "^4.16.0", "browserslist": "^4.16.0",

View File

@@ -1,5 +1,19 @@
# @rocket/cli # @rocket/cli
## 0.1.3
### Patch Changes
- 3468ff9: Pass prefix to rollup-plugin-html so assets can still be extracted
- Updated dependencies [3468ff9]
- @rocket/building-rollup@0.1.1
## 0.1.2
### Patch Changes
- 641c7e5: Add a pathPrefix option to allow deployment to a subdirectory
## 0.1.1 ## 0.1.1
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@rocket/cli", "name": "@rocket/cli",
"version": "0.1.1", "version": "0.1.3",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -50,7 +50,7 @@
], ],
"dependencies": { "dependencies": {
"@11ty/eleventy": "^0.11.1", "@11ty/eleventy": "^0.11.1",
"@rocket/building-rollup": "^0.1.0", "@rocket/building-rollup": "^0.1.1",
"@rocket/core": "^0.1.0", "@rocket/core": "^0.1.0",
"@rocket/eleventy-plugin-mdjs-unified": "^0.1.0", "@rocket/eleventy-plugin-mdjs-unified": "^0.1.0",
"@rocket/eleventy-rocket-nav": "^0.1.0", "@rocket/eleventy-rocket-nav": "^0.1.0",

View File

@@ -1,13 +1,12 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */ /* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck // @ts-nocheck
import commandLineArgs from 'command-line-args';
import { rollup } from 'rollup'; import { rollup } from 'rollup';
import fs from 'fs-extra'; import fs from 'fs-extra';
import { copy } from '@web/rollup-plugin-copy'; import { copy } from '@web/rollup-plugin-copy';
import { createMpaConfig } from '@rocket/building-rollup'; import { createMpaConfig } from '@rocket/building-rollup';
import { addPlugin } from 'plugins-manager'; import { addPlugin, adjustPluginOptions } from 'plugins-manager';
/** /**
* @param {object} config * @param {object} config
@@ -24,6 +23,22 @@ async function buildAndWrite(config) {
} }
async function productionBuild(config) { async function productionBuild(config) {
const defaultSetupPlugins = [
addPlugin({
name: 'copy',
plugin: copy,
options: {
patterns: ['!(*.md|*.html)*', '_merged_assets/_static/**/*.{png,gif,jpg,json,css,svg,ico}'],
rootDir: config.outputDevDir,
},
}),
];
if (config.pathPrefix) {
defaultSetupPlugins.push(
adjustPluginOptions('html', { absolutePathPrefix: config.pathPrefix }),
);
}
const mpaConfig = createMpaConfig({ const mpaConfig = createMpaConfig({
input: '**/*.html', input: '**/*.html',
output: { output: {
@@ -33,17 +48,7 @@ async function productionBuild(config) {
rootDir: config.outputDevDir, rootDir: config.outputDevDir,
absoluteBaseUrl: config.absoluteBaseUrl, absoluteBaseUrl: config.absoluteBaseUrl,
setupPlugins: [ setupPlugins: [
addPlugin({ ...defaultSetupPlugins,
name: 'copy',
plugin: copy,
options: {
patterns: [
'!(*.md|*.html)*',
'_merged_assets/_static/**/*.{png,gif,jpg,json,css,svg,ico}',
],
rootDir: config.outputDevDir,
},
}),
...config.setupDevAndBuildPlugins, ...config.setupDevAndBuildPlugins,
...config.setupBuildPlugins, ...config.setupBuildPlugins,
], ],
@@ -60,26 +65,10 @@ export class RocketBuild {
return config; return config;
} }
async setup({ config, argv }) { async setup({ config }) {
const buildDefinitions = [
{
name: 'mode',
alias: 'm',
type: String,
defaultValue: 'full',
description: 'What build to run [full, site, optimize]',
},
{ name: 'help', type: Boolean, description: 'See all options' },
];
const buildOptions = commandLineArgs(buildDefinitions, { argv });
this.config = { this.config = {
...config,
emptyOutputDir: true, emptyOutputDir: true,
build: { ...config,
...config.build,
...buildOptions,
},
}; };
} }

View File

@@ -79,28 +79,12 @@ export class RocketCli {
const rel = path.relative(process.cwd(), path.join(__dirname)); const rel = path.relative(process.cwd(), path.join(__dirname));
const relCwdPathToConfig = path.join(rel, 'shared', '.eleventy.cjs'); const relCwdPathToConfig = path.join(rel, 'shared', '.eleventy.cjs');
elev.setConfigPathOverride(relCwdPathToConfig); elev.setConfigPathOverride(relCwdPathToConfig);
// elev.setDryRun(true); // do not write to file system
await elev.init(); await elev.init();
if (this.config.watch) { if (this.config.watch) {
elev.watch(); elev.watch();
} }
// // 11ty will bind this hook to itself
// const that = this;
// elev.config.filters['hook-for-rocket'] = async function hook(html, outputPath) {
// // that.requestUpdate();
// // const data = await this.getData();
// // const { layout, title, inputPath } = data;
// // const url = data.page.url;
// // for (const plugin of that.plugins) {
// // if (typeof plugin.transformHtml === 'function') {
// // await plugin.transformHtml({ html, inputPath, outputPath, layout, title, url });
// // }
// // }
// return html;
// };
this.eleventy = elev; this.eleventy = elev;
} }
} }
@@ -135,13 +119,13 @@ export class RocketCli {
if (this.config) { if (this.config) {
for (const plugin of this.config.plugins) { for (const plugin of this.config.plugins) {
if (this.considerPlugin(plugin)) { if (this.considerPlugin(plugin)) {
if (typeof plugin.setup === 'function') {
await plugin.setup({ config: this.config, argv: this.subArgv });
}
if (typeof plugin.setupCommand === 'function') { if (typeof plugin.setupCommand === 'function') {
this.config = plugin.setupCommand(this.config); this.config = plugin.setupCommand(this.config);
} }
if (typeof plugin.setup === 'function') {
await plugin.setup({ config: this.config, argv: this.subArgv });
}
} }
} }
} }

View File

@@ -9,6 +9,14 @@ import { metaConfigToWebDevServerConfig } from 'plugins-manager';
export class RocketStart { export class RocketStart {
commands = ['start']; commands = ['start'];
/**
* @param {RocketCliOptions} config
*/
setupCommand(config) {
delete config.pathPrefix;
return config;
}
/** /**
* @param {object} options * @param {object} options
* @param {RocketCliOptions} options.config * @param {RocketCliOptions} options.config

View File

@@ -203,35 +203,53 @@ describe('RocketCli e2e', () => {
); );
}); });
it.skip('can add a pathprefix for the build output', async () => { it('can add a pathprefix that will not influence the start command', async () => {
cli = new RocketCli({ cli = new RocketCli({
argv: [ argv: [
'build', 'start',
'--config-file', '--config-file',
path.join(__dirname, 'e2e-fixtures', 'content', 'eleventy.rocket.config.js'), path.join(__dirname, 'e2e-fixtures', 'content', 'pathprefix.rocket.config.js'),
], ],
}); });
await execute(); await execute();
// const indexHtml = await readOutput('index.html', { const linkHtml = await readOutput('link/index.html', {
// type: 'start', type: 'start',
// }); });
// expect(indexHtml).to.equal("<p>Markdown in 'docs/page/index.md'</p>"); expect(linkHtml).to.equal(
['<p><a href="../../">home</a></p>', '<p><a href="/">absolute home</a></p>'].join('\n'),
);
const assetHtml = await readOutput('use-assets/index.html', {
type: 'start',
});
expect(assetHtml).to.equal('<link rel="stylesheet" href="/_merged_assets/some.css">');
}); });
it.skip('works with an empty object in rocket.config.js', async () => { it('can add a pathPrefix that will be used in the build command', async () => {
cli = new RocketCli({ cli = new RocketCli({
argv: [ argv: [
'build', 'build',
'--config-file', '--config-file',
path.join(__dirname, 'e2e-fixtures', 'content', 'empty.rocket.config.js'), path.join(__dirname, 'e2e-fixtures', 'content', 'pathPrefix.rocket.config.js'),
], ],
}); });
await execute(); await execute();
// const indexHtml = await readOutput('index.html', { const linkHtml = await readOutput('link/index.html', {
// type: 'start', stripServiceWorker: true,
// }); stripToBody: true,
// expect(indexHtml).to.equal("<p>Markdown in 'docs/page/index.md'</p>"); });
expect(linkHtml).to.equal(
[
'<p><a href="../../">home</a></p>',
'<p><a href="/my-sub-folder/">absolute home</a></p>',
].join('\n'),
);
const assetHtml = await readOutput('use-assets/index.html', {
stripServiceWorker: true,
});
expect(assetHtml).to.equal(
'<html><head><link rel="stylesheet" href="../41297ffa.css">\n\n\n\n</head><body>\n\n</body></html>',
);
}); });
}); });

View File

@@ -0,0 +1 @@
body { background: green; }

View File

@@ -1 +1,7 @@
---
layout: layout.njk
---
[home](../index.md) [home](../index.md)
<a href="{{ '/' | url }}">absolute home</a>

View File

@@ -0,0 +1,5 @@
---
layout: layout.njk
---
<link rel="stylesheet" href="{{ '/_assets/some.css' | asset | url }}">

View File

@@ -1,6 +1,6 @@
/** @type {Partial<import("../../../types/main").RocketCliOptions>} */ /** @type {Partial<import("../../../types/main").RocketCliOptions>} */
const config = { const config = {
pathPrefix: 'my-sub-folder', pathPrefix: '/my-sub-folder/',
}; };
export default config; export default config;

View File

@@ -1,6 +1,13 @@
# @rocket/drawer # @rocket/drawer
## 0.1.1
### Patch Changes
- d955b43: reset translation on teardown overlay controller
## 0.1.0 ## 0.1.0
### Minor Changes ### Minor Changes
- 1971f5d: Initial Release - 1971f5d: Initial Release

View File

@@ -1,6 +1,6 @@
{ {
"name": "@rocket/drawer", "name": "@rocket/drawer",
"version": "0.1.0", "version": "0.1.1",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },

View File

@@ -64,6 +64,11 @@ export class RocketDrawer extends OverlayMixin(LitElement) {
} }
} }
_teardownOverlayCtrl() {
super._teardownOverlayCtrl();
this._overlayCtrl.contentNode.style.transform = 'translateX(0)';
}
/** @param {import('lit-element').PropertyValues } changedProperties */ /** @param {import('lit-element').PropertyValues } changedProperties */
updated(changedProperties) { updated(changedProperties) {
super.updated(changedProperties); super.updated(changedProperties);

View File

@@ -31,7 +31,7 @@
"mdjs" "mdjs"
], ],
"dependencies": { "dependencies": {
"@mdjs/core": "^0.6.0", "@mdjs/core": "^0.6.1",
"es-module-lexer": "^0.3.26", "es-module-lexer": "^0.3.26",
"unist-util-visit": "^2.0.3" "unist-util-visit": "^2.0.3"
}, },

View File

@@ -1,6 +1,15 @@
# @rocket/launch # @rocket/launch
## 0.1.1
### Patch Changes
- 3468ff9: Do not double url social media images
- Updated dependencies [d955b43]
- @rocket/drawer@0.1.1
## 0.1.0 ## 0.1.0
### Minor Changes ### Minor Changes
- 1971f5d: Initial Release - 1971f5d: Initial Release

View File

@@ -1,6 +1,6 @@
{ {
"name": "@rocket/launch", "name": "@rocket/launch",
"version": "0.1.0", "version": "0.1.1",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -31,7 +31,7 @@
"preset" "preset"
], ],
"dependencies": { "dependencies": {
"@rocket/drawer": "^0.1.0", "@rocket/drawer": "^0.1.1",
"@rocket/navigation": "^0.1.0" "@rocket/navigation": "^0.1.0"
} }
} }

View File

@@ -26,7 +26,7 @@
<meta property="og:title" content="{{ _pageTitle }}"/> <meta property="og:title" content="{{ _pageTitle }}"/>
<meta property="og:type" content="website"/> <meta property="og:type" content="website"/>
{% set _socialMediaImage = '/_assets/social-media-image.jpg' | asset | url %} {% set _socialMediaImage = '/_assets/social-media-image.jpg' | asset %}
{% if socialMediaImage %} {% if socialMediaImage %}
{% set _socialMediaImage = socialMediaImage %} {% set _socialMediaImage = socialMediaImage %}
{% endif %} {% endif %}

View File

@@ -1860,10 +1860,10 @@
dependencies: dependencies:
glob "^7.0.0" glob "^7.0.0"
"@web/rollup-plugin-html@^1.3.3": "@web/rollup-plugin-html@^1.4.0":
version "1.3.3" version "1.4.0"
resolved "https://registry.yarnpkg.com/@web/rollup-plugin-html/-/rollup-plugin-html-1.3.3.tgz#366f1a889a93ef6a26afd227611deb23c52cd232" resolved "https://registry.yarnpkg.com/@web/rollup-plugin-html/-/rollup-plugin-html-1.4.0.tgz#bf94d1ee525e5f41dc527bbff9f7e24973a82238"
integrity sha512-SSgL72jIV0+N68wafDW7M40yry2RfJfcZsVOhTlir+U6RdEz0hdQPXkf/o9sHxIxo3w0sgL6tN+q7VlHMOWQGw== integrity sha512-AYOeRuNsPXQmNpxlJRFLlfVMm4EazXcJEz0bbVd6wKQVcEBM71kRboGfupxhoIkDcVyThefw9gETcMZ4ntUcTw==
dependencies: dependencies:
"@web/parse5-utils" "^1.1.2" "@web/parse5-utils" "^1.1.2"
glob "^7.1.6" glob "^7.1.6"