USGS-VIZLAB / vizlab

Package with utilities for building vizlab pages
Creative Commons Zero v1.0 Universal
25 stars 14 forks source link

Webpack #385

Closed lindsayplatt closed 6 years ago

lindsayplatt commented 6 years ago

Add the ability to use webpack. If the webpack section (https://github.com/USGS-VIZLAB/vizlab/pull/385/files#diff-0cb220d0e9525edb2082cae497231423R255) is not defined, it will skip all of this. Related to work going on over in https://github.com/USGS-VIZLAB/gage-conditions/issues/10

Even with making each .js a target, changes are not triggering a rebuild.

mwernimont commented 6 years ago

@lindsaycarr so currently we need to add each js file to the viz.yaml for this to work?

lindsayplatt commented 6 years ago

Yes, and I don't know if there is a way to get around it unless we can figure out how to get --watch to work with vizmake...but that gets complicated because webpack would need to be looking at changes in the js/___.js files. My solution here was to make it so that we didn't need to think about the structure behind the scenes.

mwernimont commented 6 years ago

Did you try the having run webpack first in the vizmake so it creates the bundle.js and then vizmake can just put the newly recreated bundle.js into the target folder. Or does that not even register as a change in the file to vizmake?

mwernimont commented 6 years ago

I think we actually talked about my above comment before, we don't want webpack running each time only just when it has to right?

lindsayplatt commented 6 years ago

Well, we still would need to have those js files as targets and then dependencies of whatever kicked off the webpack build. I opted for webpack to do all of file organization and configuration file stuff "behind the scenes" in target/

mwernimont commented 6 years ago

I'm lossed when it comes to the guts of what makes vizmake() run, so I'll trust your judgment. Maybe Alison has more constructive things to say whenever she gets back. ((✊)) Travis Build!!

aappling-usgs commented 6 years ago

Looks like some of the Travis issues are directly related to this PR:

* checking for code/documentation mismatches ... WARNING
Codoc mismatches from documentation object 'generateWebpackConfigFile':
generateWebpackConfigFile
  Code: function(file, webpack.config)
  Docs: function(webpack.config)
  Argument names in code not in docs:
    file
  Mismatches in argument names:
    Position: 1 Code: file Docs: webpack.config
* checking Rd \usage sections ... WARNING
Undocumented arguments in documentation object 'checkInstalled'
  ‘name’
Undocumented arguments in documentation object 'generateWebpackConfigFile'
  ‘webpack.config’
Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.
See chapter ���Writing R documentation files’ in the ‘Writing R
Extensions’ manual.
lindsayplatt commented 6 years ago

^ yeah, some errors seem to be because I didn't have Generate documentation with Roxygen checked in my build config...I will push up some commits soon and see what happens.

lindsayplatt commented 6 years ago

Changes based on @aappling-usgs and @lindsaycarr meeting:

lindsayplatt commented 6 years ago

We are still missing how the bundled js file in target now ends up as a script tag in the body of the index.html....

aappling-usgs commented 6 years ago

Ooh, good point. We'll need that script tag. The publish step could be responsible for just exactly that, though, and no file movements. And it could get run before the webpack call within vizmake().