From da3c6c6b057c07532a2fc6b02f17017382ede47b Mon Sep 17 00:00:00 2001 From: igor-dv Date: Wed, 10 Oct 2018 17:19:02 +0300 Subject: [PATCH 1/3] Extract commander to a separate place --- lib/core/src/server/build-dev.js | 167 +++++++++++----------------- lib/core/src/server/build-static.js | 52 ++++----- lib/core/src/server/cli/dev.js | 68 +++++++++++ lib/core/src/server/cli/index.js | 4 + lib/core/src/server/cli/prod.js | 30 +++++ lib/core/src/server/cli/utils.js | 13 +++ lib/core/src/server/middleware.js | 8 +- lib/core/src/server/utils.js | 14 --- 8 files changed, 207 insertions(+), 149 deletions(-) create mode 100644 lib/core/src/server/cli/dev.js create mode 100644 lib/core/src/server/cli/index.js create mode 100644 lib/core/src/server/cli/prod.js create mode 100644 lib/core/src/server/cli/utils.js diff --git a/lib/core/src/server/build-dev.js b/lib/core/src/server/build-dev.js index 3933263fb54a..03a5ad6b09b4 100644 --- a/lib/core/src/server/build-dev.js +++ b/lib/core/src/server/build-dev.js @@ -2,121 +2,59 @@ import express from 'express'; import https from 'https'; import ip from 'ip'; import favicon from 'serve-favicon'; -import program from 'commander'; import path from 'path'; import fs from 'fs'; import chalk from 'chalk'; -import detectFreePort from 'detect-port'; -import inquirer from 'inquirer'; import { logger } from '@storybook/node-logger'; import opn from 'opn'; - import storybook, { webpackValid } from './middleware'; -import { parseList, getEnvConfig } from './utils'; +import { getDevCli } from './cli'; import './config/env'; const defaultFavIcon = require.resolve('./public/favicon.ico'); -const getFreePort = port => - detectFreePort(port).catch(error => { - logger.error(error); - process.exit(-1); - }); - -export async function buildDev({ packageJson, ...loadOptions }) { - process.env.NODE_ENV = process.env.NODE_ENV || 'development'; - - program - .version(packageJson.version) - .option('-p, --port [number]', 'Port to run Storybook', str => parseInt(str, 10)) - .option('-h, --host [string]', 'Host to run Storybook') - .option('-s, --static-dir ', 'Directory where to load static files from') - .option('-c, --config-dir [dir-name]', 'Directory where to load Storybook configurations from') - .option( - '--https', - 'Serve Storybook over HTTPS. Note: You must provide your own certificate information.' - ) - .option( - '--ssl-ca ', - 'Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)', - parseList - ) - .option('--ssl-cert ', 'Provide an SSL certificate. (Required with --https)') - .option('--ssl-key ', 'Provide an SSL key. (Required with --https)') - .option('--smoke-test', 'Exit after successful start') - .option('--ci', "CI mode (skip interactive prompts, don't open browser") - .option('--quiet', 'Suppress verbose build output') - .parse(process.argv); - - logger.info(chalk.bold(`${packageJson.name} v${packageJson.version}`) + chalk.reset('\n')); - - // The key is the field created in `program` variable for - // each command line argument. Value is the env variable. - getEnvConfig(program, { - port: 'SBCONFIG_PORT', - host: 'SBCONFIG_HOSTNAME', - staticDir: 'SBCONFIG_STATIC_DIR', - configDir: 'SBCONFIG_CONFIG_DIR', - }); - - const port = await getFreePort(program.port); - - if (!program.ci && !program.smokeTest && program.port != null && port !== program.port) { - const { shouldChangePort } = await inquirer.prompt({ - type: 'confirm', - default: true, - name: 'shouldChangePort', - message: `Port ${program.port} is not available. -Would you like to run Storybook on port ${port} instead?`, - }); - if (!shouldChangePort) { - process.exit(1); - } +function getServer(app, options) { + if (!options.https) { + return app; } - // Used with `app.listen` below - const listenAddr = [port]; - - if (program.host) { - listenAddr.push(program.host); + if (!options.sslCert) { + logger.error('Error: --ssl-cert is required with --https'); + process.exit(-1); } - const app = express(); - let server = app; - - if (program.https) { - if (!program.sslCert) { - logger.error('Error: --ssl-cert is required with --https'); - process.exit(-1); - } - if (!program.sslKey) { - logger.error('Error: --ssl-key is required with --https'); - process.exit(-1); - } + if (!options.sslKey) { + logger.error('Error: --ssl-key is required with --https'); + process.exit(-1); + } - const sslOptions = { - ca: (program.sslCa || []).map(ca => fs.readFileSync(ca, 'utf-8')), - cert: fs.readFileSync(program.sslCert, 'utf-8'), - key: fs.readFileSync(program.sslKey, 'utf-8'), - }; + const sslOptions = { + ca: (options.sslCa || []).map(ca => fs.readFileSync(ca, 'utf-8')), + cert: fs.readFileSync(options.sslCert, 'utf-8'), + key: fs.readFileSync(options.sslKey, 'utf-8'), + }; - server = https.createServer(sslOptions, app); - } + return https.createServer(sslOptions, app); +} +function applyStatic(app, options) { + const { staticDir } = options; let hasCustomFavicon = false; - if (program.staticDir) { - program.staticDir = parseList(program.staticDir); - program.staticDir.forEach(dir => { + if (staticDir) { + staticDir.forEach(dir => { const staticPath = path.resolve(dir); + if (!fs.existsSync(staticPath)) { logger.error(`Error: no such directory to load static files: ${staticPath}`); process.exit(-1); } + logger.info(`=> Loading static files from: ${staticPath} .`); app.use(express.static(staticPath, { index: false })); const faviconPath = path.resolve(staticPath, 'favicon.ico'); + if (fs.existsSync(faviconPath)) { hasCustomFavicon = true; app.use(favicon(faviconPath)); @@ -127,21 +65,17 @@ Would you like to run Storybook on port ${port} instead?`, if (!hasCustomFavicon) { app.use(favicon(defaultFavIcon)); } +} - // Build the webpack configuration using the `baseConfig` - // custom `.babelrc` file and `webpack.config.js` files - const configDir = program.configDir || './.storybook'; - - // NOTE changes to env should be done before calling `getBaseConfig` - // `getBaseConfig` function which is called inside the middleware - app.use(storybook(configDir, loadOptions, program.quiet)); - +function listenToServer(server, listenAddr) { let serverResolve = () => {}; let serverReject = () => {}; + const serverListening = new Promise((resolve, reject) => { serverResolve = resolve; serverReject = reject; }); + server.listen(...listenAddr, error => { if (error) { serverReject(error); @@ -150,24 +84,57 @@ Would you like to run Storybook on port ${port} instead?`, } }); + return serverListening; +} + +export async function buildDevStandalone(options) { + const { port, host } = options; + + // Used with `app.listen` below + const listenAddr = [port]; + + if (host) { + listenAddr.push(host); + } + + const app = express(); + const server = getServer(app, options); + + applyStatic(app, options); + + app.use(storybook(options)); + + const serverListening = listenToServer(server, listenAddr); + try { const [stats] = await Promise.all([webpackValid, serverListening]); - const proto = program.https ? 'https' : 'http'; - const address = `${proto}://${program.host || 'localhost'}:${port}/`; + const proto = options.https ? 'https' : 'http'; + const address = `${proto}://${host || 'localhost'}:${port}/`; const networkAddress = `${proto}://${ip.address()}:${port}/`; logger.info(`Storybook started on => ${chalk.cyan(address)}`); logger.info(`Available on the network at => ${chalk.cyan(networkAddress)}\n`); - if (program.smokeTest) { + + if (options.smokeTest) { process.exit(stats.toJson().warnings.length ? 1 : 0); - } else if (!program.ci) { + } else if (!options.ci) { opn(address); } } catch (error) { if (error instanceof Error) { logger.error(error); } - if (program.smokeTest) { + if (options.smokeTest) { process.exit(1); } } } + +export async function buildDev({ packageJson, ...loadOptions }) { + const cliOptions = await getDevCli(packageJson); + + await buildDevStandalone({ + ...cliOptions, + ...loadOptions, + configDir: cliOptions.configDir || './.storybook', + }); +} diff --git a/lib/core/src/server/build-static.js b/lib/core/src/server/build-static.js index 21a0071e7dbb..0a1c7c562522 100644 --- a/lib/core/src/server/build-static.js +++ b/lib/core/src/server/build-static.js @@ -1,39 +1,16 @@ import webpack from 'webpack'; -import program from 'commander'; import path from 'path'; import fs from 'fs'; -import chalk from 'chalk'; import shelljs from 'shelljs'; import { logger } from '@storybook/node-logger'; -import { parseList, getEnvConfig } from './utils'; +import { getProdCli } from './cli'; import './config/env'; import loadConfig from './config'; const defaultFavIcon = require.resolve('./public/favicon.ico'); -export function buildStatic({ packageJson, ...loadOptions }) { - process.env.NODE_ENV = process.env.NODE_ENV || 'production'; - - program - .version(packageJson.version) - .option('-s, --static-dir ', 'Directory where to load static files from', parseList) - .option('-o, --output-dir [dir-name]', 'Directory where to store built files') - .option('-c, --config-dir [dir-name]', 'Directory where to load Storybook configurations from') - .option('-w, --watch', 'Enable watch mode') - .parse(process.argv); - - logger.info(chalk.bold(`${packageJson.name} v${packageJson.version}\n`)); - - // The key is the field created in `program` variable for - // each command line argument. Value is the env variable. - getEnvConfig(program, { - staticDir: 'SBCONFIG_STATIC_DIR', - outputDir: 'SBCONFIG_OUTPUT_DIR', - configDir: 'SBCONFIG_CONFIG_DIR', - }); - - const configDir = program.configDir || './.storybook'; - const outputDir = program.outputDir || './storybook-static'; +export function buildStaticStandalone(options) { + const { outputDir, staticDir, watch } = options; // create output directory if not exists shelljs.mkdir('-p', path.resolve(outputDir)); @@ -47,14 +24,14 @@ export function buildStatic({ packageJson, ...loadOptions }) { const config = loadConfig({ configType: 'PRODUCTION', corePresets: [require.resolve('./core-preset-prod.js')], - configDir, - ...loadOptions, + ...options, }); + config.output.path = path.resolve(outputDir); // copy all static files - if (program.staticDir) { - program.staticDir.forEach(dir => { + if (staticDir) { + staticDir.forEach(dir => { if (!fs.existsSync(dir)) { logger.error(`Error: no such directory to load static files: ${dir}`); process.exit(-1); @@ -77,10 +54,23 @@ export function buildStatic({ packageJson, ...loadOptions }) { } logger.info('Building storybook completed.'); }; + const compiler = webpack(config); - if (program.watch) { + + if (watch) { compiler.watch({}, webpackCb); } else { compiler.run(webpackCb); } } + +export function buildStatic({ packageJson, ...loadOptions }) { + const cliOptions = getProdCli(packageJson); + + buildStaticStandalone({ + ...cliOptions, + ...loadOptions, + configDir: cliOptions.configDir || './.storybook', + outputDir: cliOptions.outputDir || './storybook-static', + }); +} diff --git a/lib/core/src/server/cli/dev.js b/lib/core/src/server/cli/dev.js new file mode 100644 index 000000000000..939f471a3318 --- /dev/null +++ b/lib/core/src/server/cli/dev.js @@ -0,0 +1,68 @@ +import program from 'commander'; +import chalk from 'chalk'; +import detectFreePort from 'detect-port'; +import inquirer from 'inquirer'; +import { logger } from '@storybook/node-logger'; +import { parseList, getEnvConfig } from './utils'; + +const getFreePort = port => + detectFreePort(port).catch(error => { + logger.error(error); + process.exit(-1); + }); + +async function getCLI(packageJson) { + process.env.NODE_ENV = process.env.NODE_ENV || 'development'; + + program + .version(packageJson.version) + .option('-p, --port [number]', 'Port to run Storybook', str => parseInt(str, 10)) + .option('-h, --host [string]', 'Host to run Storybook') + .option('-s, --static-dir ', 'Directory where to load static files from', parseList) + .option('-c, --config-dir [dir-name]', 'Directory where to load Storybook configurations from') + .option( + '--https', + 'Serve Storybook over HTTPS. Note: You must provide your own certificate information.' + ) + .option( + '--ssl-ca ', + 'Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)', + parseList + ) + .option('--ssl-cert ', 'Provide an SSL certificate. (Required with --https)') + .option('--ssl-key ', 'Provide an SSL key. (Required with --https)') + .option('--smoke-test', 'Exit after successful start') + .option('--ci', "CI mode (skip interactive prompts, don't open browser") + .option('--quiet', 'Suppress verbose build output') + .parse(process.argv); + + logger.info(chalk.bold(`${packageJson.name} v${packageJson.version}`) + chalk.reset('\n')); + + // The key is the field created in `program` variable for + // each command line argument. Value is the env variable. + getEnvConfig(program, { + port: 'SBCONFIG_PORT', + host: 'SBCONFIG_HOSTNAME', + staticDir: 'SBCONFIG_STATIC_DIR', + configDir: 'SBCONFIG_CONFIG_DIR', + }); + + const port = await getFreePort(program.port); + + if (!program.ci && !program.smokeTest && program.port != null && port !== program.port) { + const { shouldChangePort } = await inquirer.prompt({ + type: 'confirm', + default: true, + name: 'shouldChangePort', + message: `Port ${program.port} is not available. +Would you like to run Storybook on port ${port} instead?`, + }); + if (!shouldChangePort) { + process.exit(1); + } + } + + return { ...program, port }; +} + +export default getCLI; diff --git a/lib/core/src/server/cli/index.js b/lib/core/src/server/cli/index.js new file mode 100644 index 000000000000..9ff64a635483 --- /dev/null +++ b/lib/core/src/server/cli/index.js @@ -0,0 +1,4 @@ +import getDevCli from './dev'; +import getProdCli from './prod'; + +export { getDevCli, getProdCli }; diff --git a/lib/core/src/server/cli/prod.js b/lib/core/src/server/cli/prod.js new file mode 100644 index 000000000000..078c9eda2793 --- /dev/null +++ b/lib/core/src/server/cli/prod.js @@ -0,0 +1,30 @@ +import program from 'commander'; +import chalk from 'chalk'; +import { logger } from '@storybook/node-logger'; +import { parseList, getEnvConfig } from './utils'; + +function getCLI(packageJson) { + process.env.NODE_ENV = process.env.NODE_ENV || 'production'; + + program + .version(packageJson.version) + .option('-s, --static-dir ', 'Directory where to load static files from', parseList) + .option('-o, --output-dir [dir-name]', 'Directory where to store built files') + .option('-c, --config-dir [dir-name]', 'Directory where to load Storybook configurations from') + .option('-w, --watch', 'Enable watch mode') + .parse(process.argv); + + logger.info(chalk.bold(`${packageJson.name} v${packageJson.version}\n`)); + + // The key is the field created in `program` variable for + // each command line argument. Value is the env variable. + getEnvConfig(program, { + staticDir: 'SBCONFIG_STATIC_DIR', + outputDir: 'SBCONFIG_OUTPUT_DIR', + configDir: 'SBCONFIG_CONFIG_DIR', + }); + + return { ...program }; +} + +export default getCLI; diff --git a/lib/core/src/server/cli/utils.js b/lib/core/src/server/cli/utils.js new file mode 100644 index 000000000000..b13d04e1181c --- /dev/null +++ b/lib/core/src/server/cli/utils.js @@ -0,0 +1,13 @@ +export function parseList(str) { + return str.split(','); +} + +export function getEnvConfig(program, configEnv) { + Object.keys(configEnv).forEach(fieldName => { + const envVarName = configEnv[fieldName]; + const envVarValue = process.env[envVarName]; + if (envVarValue) { + program[fieldName] = envVarValue; // eslint-disable-line + } + }); +} diff --git a/lib/core/src/server/middleware.js b/lib/core/src/server/middleware.js index e35f0398ae69..9d035953b330 100644 --- a/lib/core/src/server/middleware.js +++ b/lib/core/src/server/middleware.js @@ -14,15 +14,15 @@ export const webpackValid = new Promise((resolve, reject) => { webpackReject = reject; }); -export default function(configDir, loadOptions, quiet) { +export default function(options) { + const { configDir } = options; + // Build the webpack configuration using the `getBaseConfig` // custom `.babelrc` file and `webpack.config.js` files const config = loadConfig({ configType: 'DEVELOPMENT', corePresets: [require.resolve('./core-preset-dev.js')], - configDir, - quiet, - ...loadOptions, + ...options, }); const middlewareFn = getMiddleware(configDir); diff --git a/lib/core/src/server/utils.js b/lib/core/src/server/utils.js index 4cf9e6905a09..6bb4cc0c5667 100644 --- a/lib/core/src/server/utils.js +++ b/lib/core/src/server/utils.js @@ -1,20 +1,6 @@ import path from 'path'; import fs from 'fs'; -export function parseList(str) { - return str.split(','); -} - -export function getEnvConfig(program, configEnv) { - Object.keys(configEnv).forEach(fieldName => { - const envVarName = configEnv[fieldName]; - const envVarValue = process.env[envVarName]; - if (envVarValue) { - program[fieldName] = envVarValue; // eslint-disable-line - } - }); -} - export function getMiddleware(configDir) { const middlewarePath = path.resolve(configDir, 'middleware.js'); if (fs.existsSync(middlewarePath)) { From b9fb04b185df2877b91bdce17cedf10711553832 Mon Sep 17 00:00:00 2001 From: igor-dv Date: Wed, 10 Oct 2018 18:27:18 +0300 Subject: [PATCH 2/3] Expose standalone build from @storybook/core --- lib/core/src/server/standalone.js | 24 ++++++++++++++++++++++++ lib/core/standalone.js | 3 +++ 2 files changed, 27 insertions(+) create mode 100644 lib/core/src/server/standalone.js create mode 100644 lib/core/standalone.js diff --git a/lib/core/src/server/standalone.js b/lib/core/src/server/standalone.js new file mode 100644 index 000000000000..b4dccae05e8c --- /dev/null +++ b/lib/core/src/server/standalone.js @@ -0,0 +1,24 @@ +import { buildStaticStandalone } from './build-static'; +import { buildDevStandalone } from './build-dev'; + +async function build(options = {}, frameworkOptions = {}) { + const { mode = 'dev' } = options; + + const commonOptions = { + ...options, + ...frameworkOptions, + frameworkPresets: [...options.frameworkPresets, ...(frameworkOptions.frameworkPresets || [])], + }; + + if (mode === 'dev') { + return buildDevStandalone(commonOptions); + } + + if (mode === 'static') { + return buildStaticStandalone(commonOptions); + } + + throw new Error(`'mode' parameter should be either 'dev' or 'static'`); +} + +export default build; diff --git a/lib/core/standalone.js b/lib/core/standalone.js new file mode 100644 index 000000000000..48aabc274024 --- /dev/null +++ b/lib/core/standalone.js @@ -0,0 +1,3 @@ +const build = require('./dist/server/standalone').default; + +module.exports = build; From 2e11d18a87a87a429cc22f425f2699a0714b937d Mon Sep 17 00:00:00 2001 From: igor-dv Date: Wed, 10 Oct 2018 18:29:11 +0300 Subject: [PATCH 3/3] Put standalone.js to every app --- app/angular/src/server/index.js | 1 - app/angular/standalone.js | 8 ++++++++ app/ember/src/server/index.js | 1 - app/ember/standalone.js | 8 ++++++++ app/html/src/server/index.js | 1 - app/html/standalone.js | 8 ++++++++ app/marko/src/server/index.js | 1 - app/marko/standalone.js | 8 ++++++++ app/mithril/src/server/index.js | 1 - app/mithril/standalone.js | 8 ++++++++ app/polymer/src/server/index.js | 1 - app/polymer/standalone.js | 8 ++++++++ app/react/src/server/index.js | 1 - app/react/standalone.js | 8 ++++++++ app/riot/src/server/index.js | 1 - app/riot/standalone.js | 8 ++++++++ app/svelte/src/server/build.js | 1 - app/svelte/src/server/index.js | 1 - app/svelte/standalone.js | 8 ++++++++ app/vue/src/server/index.js | 1 - app/vue/standalone.js | 8 ++++++++ 21 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 app/angular/standalone.js create mode 100644 app/ember/standalone.js create mode 100644 app/html/standalone.js create mode 100644 app/marko/standalone.js create mode 100644 app/mithril/standalone.js create mode 100644 app/polymer/standalone.js create mode 100644 app/react/standalone.js create mode 100644 app/riot/standalone.js create mode 100644 app/svelte/standalone.js create mode 100644 app/vue/standalone.js diff --git a/app/angular/src/server/index.js b/app/angular/src/server/index.js index 15b113175abe..774d96025a84 100755 --- a/app/angular/src/server/index.js +++ b/app/angular/src/server/index.js @@ -1,5 +1,4 @@ import { buildDev } from '@storybook/core/server'; - import options from './options'; buildDev(options); diff --git a/app/angular/standalone.js b/app/angular/standalone.js new file mode 100644 index 000000000000..1b1febe0d3bb --- /dev/null +++ b/app/angular/standalone.js @@ -0,0 +1,8 @@ +const build = require('@storybook/core/standalone'); +const frameworkOptions = require('./dist/server/options').default; + +async function buildStandalone(options) { + return build(options, frameworkOptions); +} + +module.exports = buildStandalone; diff --git a/app/ember/src/server/index.js b/app/ember/src/server/index.js index 15b113175abe..774d96025a84 100644 --- a/app/ember/src/server/index.js +++ b/app/ember/src/server/index.js @@ -1,5 +1,4 @@ import { buildDev } from '@storybook/core/server'; - import options from './options'; buildDev(options); diff --git a/app/ember/standalone.js b/app/ember/standalone.js new file mode 100644 index 000000000000..1b1febe0d3bb --- /dev/null +++ b/app/ember/standalone.js @@ -0,0 +1,8 @@ +const build = require('@storybook/core/standalone'); +const frameworkOptions = require('./dist/server/options').default; + +async function buildStandalone(options) { + return build(options, frameworkOptions); +} + +module.exports = buildStandalone; diff --git a/app/html/src/server/index.js b/app/html/src/server/index.js index 15b113175abe..774d96025a84 100755 --- a/app/html/src/server/index.js +++ b/app/html/src/server/index.js @@ -1,5 +1,4 @@ import { buildDev } from '@storybook/core/server'; - import options from './options'; buildDev(options); diff --git a/app/html/standalone.js b/app/html/standalone.js new file mode 100644 index 000000000000..1b1febe0d3bb --- /dev/null +++ b/app/html/standalone.js @@ -0,0 +1,8 @@ +const build = require('@storybook/core/standalone'); +const frameworkOptions = require('./dist/server/options').default; + +async function buildStandalone(options) { + return build(options, frameworkOptions); +} + +module.exports = buildStandalone; diff --git a/app/marko/src/server/index.js b/app/marko/src/server/index.js index 15b113175abe..774d96025a84 100755 --- a/app/marko/src/server/index.js +++ b/app/marko/src/server/index.js @@ -1,5 +1,4 @@ import { buildDev } from '@storybook/core/server'; - import options from './options'; buildDev(options); diff --git a/app/marko/standalone.js b/app/marko/standalone.js new file mode 100644 index 000000000000..1b1febe0d3bb --- /dev/null +++ b/app/marko/standalone.js @@ -0,0 +1,8 @@ +const build = require('@storybook/core/standalone'); +const frameworkOptions = require('./dist/server/options').default; + +async function buildStandalone(options) { + return build(options, frameworkOptions); +} + +module.exports = buildStandalone; diff --git a/app/mithril/src/server/index.js b/app/mithril/src/server/index.js index 15b113175abe..774d96025a84 100755 --- a/app/mithril/src/server/index.js +++ b/app/mithril/src/server/index.js @@ -1,5 +1,4 @@ import { buildDev } from '@storybook/core/server'; - import options from './options'; buildDev(options); diff --git a/app/mithril/standalone.js b/app/mithril/standalone.js new file mode 100644 index 000000000000..1b1febe0d3bb --- /dev/null +++ b/app/mithril/standalone.js @@ -0,0 +1,8 @@ +const build = require('@storybook/core/standalone'); +const frameworkOptions = require('./dist/server/options').default; + +async function buildStandalone(options) { + return build(options, frameworkOptions); +} + +module.exports = buildStandalone; diff --git a/app/polymer/src/server/index.js b/app/polymer/src/server/index.js index 15b113175abe..774d96025a84 100755 --- a/app/polymer/src/server/index.js +++ b/app/polymer/src/server/index.js @@ -1,5 +1,4 @@ import { buildDev } from '@storybook/core/server'; - import options from './options'; buildDev(options); diff --git a/app/polymer/standalone.js b/app/polymer/standalone.js new file mode 100644 index 000000000000..1b1febe0d3bb --- /dev/null +++ b/app/polymer/standalone.js @@ -0,0 +1,8 @@ +const build = require('@storybook/core/standalone'); +const frameworkOptions = require('./dist/server/options').default; + +async function buildStandalone(options) { + return build(options, frameworkOptions); +} + +module.exports = buildStandalone; diff --git a/app/react/src/server/index.js b/app/react/src/server/index.js index 15b113175abe..774d96025a84 100755 --- a/app/react/src/server/index.js +++ b/app/react/src/server/index.js @@ -1,5 +1,4 @@ import { buildDev } from '@storybook/core/server'; - import options from './options'; buildDev(options); diff --git a/app/react/standalone.js b/app/react/standalone.js new file mode 100644 index 000000000000..1b1febe0d3bb --- /dev/null +++ b/app/react/standalone.js @@ -0,0 +1,8 @@ +const build = require('@storybook/core/standalone'); +const frameworkOptions = require('./dist/server/options').default; + +async function buildStandalone(options) { + return build(options, frameworkOptions); +} + +module.exports = buildStandalone; diff --git a/app/riot/src/server/index.js b/app/riot/src/server/index.js index 15b113175abe..774d96025a84 100644 --- a/app/riot/src/server/index.js +++ b/app/riot/src/server/index.js @@ -1,5 +1,4 @@ import { buildDev } from '@storybook/core/server'; - import options from './options'; buildDev(options); diff --git a/app/riot/standalone.js b/app/riot/standalone.js new file mode 100644 index 000000000000..1b1febe0d3bb --- /dev/null +++ b/app/riot/standalone.js @@ -0,0 +1,8 @@ +const build = require('@storybook/core/standalone'); +const frameworkOptions = require('./dist/server/options').default; + +async function buildStandalone(options) { + return build(options, frameworkOptions); +} + +module.exports = buildStandalone; diff --git a/app/svelte/src/server/build.js b/app/svelte/src/server/build.js index 24f2ffb2e140..d8abf06a4396 100755 --- a/app/svelte/src/server/build.js +++ b/app/svelte/src/server/build.js @@ -1,5 +1,4 @@ import { buildStatic } from '@storybook/core/server'; - import options from './options'; buildStatic(options); diff --git a/app/svelte/src/server/index.js b/app/svelte/src/server/index.js index 15b113175abe..774d96025a84 100755 --- a/app/svelte/src/server/index.js +++ b/app/svelte/src/server/index.js @@ -1,5 +1,4 @@ import { buildDev } from '@storybook/core/server'; - import options from './options'; buildDev(options); diff --git a/app/svelte/standalone.js b/app/svelte/standalone.js new file mode 100644 index 000000000000..1b1febe0d3bb --- /dev/null +++ b/app/svelte/standalone.js @@ -0,0 +1,8 @@ +const build = require('@storybook/core/standalone'); +const frameworkOptions = require('./dist/server/options').default; + +async function buildStandalone(options) { + return build(options, frameworkOptions); +} + +module.exports = buildStandalone; diff --git a/app/vue/src/server/index.js b/app/vue/src/server/index.js index 15b113175abe..774d96025a84 100755 --- a/app/vue/src/server/index.js +++ b/app/vue/src/server/index.js @@ -1,5 +1,4 @@ import { buildDev } from '@storybook/core/server'; - import options from './options'; buildDev(options); diff --git a/app/vue/standalone.js b/app/vue/standalone.js new file mode 100644 index 000000000000..1b1febe0d3bb --- /dev/null +++ b/app/vue/standalone.js @@ -0,0 +1,8 @@ +const build = require('@storybook/core/standalone'); +const frameworkOptions = require('./dist/server/options').default; + +async function buildStandalone(options) { + return build(options, frameworkOptions); +} + +module.exports = buildStandalone;