Skip to content

Commit 8ecd615

Browse files
committed
fix: add better pre-rendering support
1 parent 70fe9b6 commit 8ecd615

File tree

9 files changed

+36
-12
lines changed

9 files changed

+36
-12
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
buildDir: __dirname + '/public',
3+
wwwDir: __dirname + '/public/',
4+
publicPath: '/public/styleguide/',
5+
};

packages/edition-twig/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
],
1414
"main": "patternlab-config.json",
1515
"scripts": {
16-
"build": "patternlab build --config ./patternlab-config.json",
16+
"build:uikit": "npm run build --prefix node_modules/@pattern-lab/uikit-workshop -- --patternlabrc $INIT_CWD/.patternlabrc.js",
17+
"build": "npm run build:uikit && patternlab build --config ./patternlab-config.json",
1718
"help": "patternlab --help",
1819
"install": "patternlab install --config ./patternlab-config.json",
19-
"serve": "patternlab serve --config ./patternlab-config.json",
20+
"serve": "npm run build:uikit && patternlab serve --config ./patternlab-config.json",
2021
"start": "npm run serve",
2122
"version": "patternlab --version"
2223
},

packages/uikit-workshop/dist/index.html

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

packages/uikit-workshop/dist/styleguide/js/patternlab-pattern.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/uikit-workshop/dist/styleguide/js/patternlab-viewer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/uikit-workshop/src/scripts/components/pl-viewport/pl-viewport.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,13 @@ class IFrame extends BaseComponent {
344344

345345
if (!patternParam) {
346346
if (window.patternData) {
347-
patternParam = window.patternData.patternPartial;
347+
if (window.patternData.patternPartial) {
348+
patternParam = window.patternData.patternPartial;
349+
} else {
350+
patternParam = 'all';
351+
}
348352
} else {
349-
patternParam = 'components-overview';
353+
patternParam = 'all';
350354
}
351355
}
352356

packages/uikit-workshop/views/partials/general-footer.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
{{{ patternData }}}
33
</script>
44

5+
<script>
6+
window.patternData = {{{ patternData }}};
7+
</script>
8+
59
<script>
610
/*!
711
* scriptLoader - v0.1

packages/uikit-workshop/webpack.config.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const selectorImporter = require('node-sass-selector-importer');
1111
const PrerenderSPAPlugin = require('prerender-spa-plugin');
1212
const CopyPlugin = require('copy-webpack-plugin');
1313
const path = require('path');
14+
const argv = require('yargs').argv;
1415

1516
const cosmiconfig = require('cosmiconfig');
1617
const explorer = cosmiconfig('patternlab');
@@ -27,8 +28,14 @@ const defaultConfig = {
2728
module.exports = async function() {
2829
return new Promise(async (resolve, reject) => {
2930
let customConfig = defaultConfig;
31+
let configToSearchFor;
32+
33+
if (argv.patternlabrc) {
34+
configToSearchFor = await explorer.loadSync(argv.patternlabrc);
35+
} else {
36+
configToSearchFor = await explorer.searchSync();
37+
}
3038

31-
const configToSearchFor = await explorer.searchSync();
3239
if (configToSearchFor) {
3340
if (configToSearchFor.config) {
3441
customConfig = configToSearchFor.config;
@@ -100,7 +107,7 @@ module.exports = async function() {
100107
},
101108
output: {
102109
path: path.resolve(process.cwd(), `${config.buildDir}/styleguide`),
103-
publicPath: '/pattern-lab/styleguide/',
110+
publicPath: `${config.publicPath}`,
104111
filename: '[name].js',
105112
chunkFilename: `js/[name]-chunk-[chunkhash].js`,
106113
},
@@ -311,6 +318,9 @@ module.exports = async function() {
311318

312319
// @todo: troubleshoot why forceInclude works w/ Penthouse directly but not w/ Critical
313320
forceInclude: [
321+
'pl-logo',
322+
'.pl-c-logo',
323+
'.pl-c-logo__img',
314324
'.pl-c-body--theme-light',
315325
'.pl-c-body--theme-sidebar',
316326
'.pl-c-body--theme-sidebar .pl-c-viewport',

0 commit comments

Comments
 (0)