Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve web modules #378

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/commands/serve-web-demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import path from 'path'

import {directoryExists} from '../utils'
import webpackServer from '../webpackServer'

/**
* Serve a web demo app from demo/src/index.js.
*/
export default function serveWebDemo(args, cb) {
let pkg = require(path.resolve('package.json'))

let dist = path.resolve('demo/dist')

let config = {
babel: {
presets: [require.resolve('babel-preset-stage-1')],
stage: 1,
},
entry: [path.resolve('demo/src/index.js')],
output: {
filename: 'demo.js',
path: dist,
publicPath: '/',
},
plugins: {
html: {
mountId: 'demo',
title: `${pkg.name} ${pkg.version} Demo`,
},
},
}

if (directoryExists('demo/public')) {
config.plugins.copy = [{from: path.resolve('demo/public'), to: dist}]
}

webpackServer(args, config, cb)
}
4 changes: 3 additions & 1 deletion src/commands/serve.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// @flow
import {INFERNO_APP, PREACT_APP, REACT_APP, REACT_COMPONENT, WEB_APP} from '../constants'
import {INFERNO_APP, PREACT_APP, REACT_APP, REACT_COMPONENT, WEB_APP, WEB_MODULE} from '../constants'
import {UserError} from '../errors'
import {getProjectType} from '../getUserConfig'
import serveInfernoApp from './serve-inferno-app'
import servePreactApp from './serve-preact-app'
import serveReactApp from './serve-react-app'
import serveReactDemo from './serve-react-demo'
import serveWebApp from './serve-web-app'
import serveWebDemo from './serve-web-demo'

import type {ErrBack} from '../types'

Expand All @@ -16,6 +17,7 @@ const SERVE_COMMANDS = {
[REACT_APP]: serveReactApp,
[REACT_COMPONENT]: serveReactDemo,
[WEB_APP]: serveWebApp,
[WEB_MODULE]: serveWebDemo,
}

/**
Expand Down
Empty file.