Skip to content

Commit

Permalink
Merge pull request #389 from lindsaycarr/webpack
Browse files Browse the repository at this point in the history
kick off different webpack build configs for dev vs prod
  • Loading branch information
aappling-usgs authored Oct 2, 2018
2 parents a74e14f + 2bbc1b3 commit f253864
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: vizlab
Type: Package
Title: Utilities for building online data visualizations
Version: 0.3.8
Date: 2018-08-07
Version: 0.3.9
Date: 2018-10-02
Author: Jordan Walker, Alison Appling, Lindsay Carr, Luke Winslow, Jordan Read, Laura DeCicco, Marty Wernimont, David Watkins
Maintainer: Alison Appling <[email protected]>
Description: Provides utility functions to organize, develop, and publish
Expand Down
9 changes: 6 additions & 3 deletions R/vizmake.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
#' a visualization.
#' @param target_names names of targets to build, or NULL for the default, as
#' passed to `remake::make()`
#' @param webpack_build_cfg character string indicating which script to run from the
#' webpack package.json file, e.g. "dev", "prod", "watch", etc. Must exist in
#' the package.json file for your viz. Defaults to `start`.
#' @param ... arguments passed to `remake::make()` (besides `target_names`,
#' above, or `remake_file`, which is fixed at 'remake.yaml')
#' @md
#' @export
vizmake <- function(target_names=NULL, ...) {

vizmake <- function(target_names=NULL, webpack_build_cfg = "start", ...) {
# check the format of the viz.yaml (limited checks so far)
validateVizYaml()

Expand Down Expand Up @@ -49,7 +52,7 @@ vizmake <- function(target_names=NULL, ...) {
if(file.exists('webpack.config.js')) {
# run webpack
message('Running webpack ', Sys.time())
webpacker()
webpacker(webpack_build_cfg)
message('Finished webpack ', Sys.time())
}

Expand Down
10 changes: 6 additions & 4 deletions R/webpacker.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#' Run webpack for the project
#'
#' This is called at the very end of `vizmake()` if you have a webpack block in your `viz.yaml`.
#' @param webpack.config list containing at least an input and output element that contain a
#' filepath for the javasript file going into webpack, and the name for the bundled file that results.
#' @param webpack_cfg character string indicating which script to run from the
#' webpack package.json file, e.g. "dev", "prod", "watch", etc. Must exist in
#' the package.json file for your viz. Defaults to `start`.
#'
#' @md
#' @export
webpacker <- function() {
webpacker <- function(webpack_build_cfg) {

# check if node, npm are installed
checkInstalled("node")
Expand All @@ -15,7 +17,7 @@ webpacker <- function() {
checkAndInstallNodeModule("webpack-cli")

## have a way to fail if `start` is not the default?
system("npm run start")
system(paste("npm run", webpack_build_cfg))
}

#' Check that a system library is installed
Expand Down

0 comments on commit f253864

Please sign in to comment.