Skip to content

Commit

Permalink
fix: add better pre-rendering support
Browse files Browse the repository at this point in the history
  • Loading branch information
sghoweri committed Apr 16, 2019
1 parent 70fe9b6 commit 8ecd615
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 12 deletions.
5 changes: 5 additions & 0 deletions packages/edition-twig/.patternlabrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
buildDir: __dirname + '/public',
wwwDir: __dirname + '/public/',
publicPath: '/public/styleguide/',
};
5 changes: 3 additions & 2 deletions packages/edition-twig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
],
"main": "patternlab-config.json",
"scripts": {
"build": "patternlab build --config ./patternlab-config.json",
"build:uikit": "npm run build --prefix node_modules/@pattern-lab/uikit-workshop -- --patternlabrc $INIT_CWD/.patternlabrc.js",
"build": "npm run build:uikit && patternlab build --config ./patternlab-config.json",
"help": "patternlab --help",
"install": "patternlab install --config ./patternlab-config.json",
"serve": "patternlab serve --config ./patternlab-config.json",
"serve": "npm run build:uikit && patternlab serve --config ./patternlab-config.json",
"start": "npm run serve",
"version": "patternlab --version"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/uikit-workshop/dist/index.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,13 @@ class IFrame extends BaseComponent {

if (!patternParam) {
if (window.patternData) {
patternParam = window.patternData.patternPartial;
if (window.patternData.patternPartial) {
patternParam = window.patternData.patternPartial;
} else {
patternParam = 'all';
}
} else {
patternParam = 'components-overview';
patternParam = 'all';
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
{{{ patternData }}}
</script>

<script>
window.patternData = {{{ patternData }}};
</script>

<script>
/*!
* scriptLoader - v0.1
Expand Down
14 changes: 12 additions & 2 deletions packages/uikit-workshop/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const selectorImporter = require('node-sass-selector-importer');
const PrerenderSPAPlugin = require('prerender-spa-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const path = require('path');
const argv = require('yargs').argv;

const cosmiconfig = require('cosmiconfig');
const explorer = cosmiconfig('patternlab');
Expand All @@ -27,8 +28,14 @@ const defaultConfig = {
module.exports = async function() {
return new Promise(async (resolve, reject) => {
let customConfig = defaultConfig;
let configToSearchFor;

if (argv.patternlabrc) {
configToSearchFor = await explorer.loadSync(argv.patternlabrc);
} else {
configToSearchFor = await explorer.searchSync();
}

const configToSearchFor = await explorer.searchSync();
if (configToSearchFor) {
if (configToSearchFor.config) {
customConfig = configToSearchFor.config;
Expand Down Expand Up @@ -100,7 +107,7 @@ module.exports = async function() {
},
output: {
path: path.resolve(process.cwd(), `${config.buildDir}/styleguide`),
publicPath: '/pattern-lab/styleguide/',
publicPath: `${config.publicPath}`,
filename: '[name].js',
chunkFilename: `js/[name]-chunk-[chunkhash].js`,
},
Expand Down Expand Up @@ -311,6 +318,9 @@ module.exports = async function() {

// @todo: troubleshoot why forceInclude works w/ Penthouse directly but not w/ Critical
forceInclude: [
'pl-logo',
'.pl-c-logo',
'.pl-c-logo__img',
'.pl-c-body--theme-light',
'.pl-c-body--theme-sidebar',
'.pl-c-body--theme-sidebar .pl-c-viewport',
Expand Down

0 comments on commit 8ecd615

Please sign in to comment.