-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use npm and webpack to build GUI frontend.
Previously, all of the JavaScript and CSS files that we wanted to use in Nengo GUI had to be part of the source tree, and included manually in a <script> or <link> tag in `page.html`. While this was a good way to start out, as we grow it limits us to only using pure JavaScript and CSS, and requires a cumbersome process to upgrade our JS/CSS dependencies. Now, we use npm to download specific versions of our frontend dependencies, and webpack to bundle all of our dependencies and our own frontend code together into a single bundle, which greatly simplifies `page.html`. Specifically, the frontend workflow now requires developers to do the following actions once: 1. Install node.js, which should come with `npm`. 2. Run `npm install`. Developers will now have all of the necessary dependencies in the node_modules folder, which is now in .gitignore. If developers are modifying or debugging frontend components, then they should run the command: npm run build which will package all of the frontend files into a non-minified JS file (which includes all of the CSS), and produce a source map, so that when debugging JavaScript files, the browser will show you the original source file rather than the gigantic bundle. If developers change any frotend files in a particular commit, they should regenerate the "production" version of the bundle that includes all of the frontend files. To do this, run: npm run release which will package all the frontend files in a minimified and optimized JS file. No source map will be produced. This keeps the size of commits small while still enabling all commits to be tested by CI. For the time being, I have limited the changes required to get npm + webpack working to the minimum number of files, which is mainly nengo.js, which "imports" all of the other files. Other changes: - In netgraph.js, we no longer have a <link> tag to get a handle to; fortunately, it's possible to get the string version of the CSS through webpack, so now we use `require` to get the CSS. - `data_to_csv.js` had to be modified to export the data_to_csv function because it's used in another file, and in tests. - Moved the styles in `main.css` to `nengo.css`, as that's the entrypoint that we use anyhow.
- Loading branch information
Showing
35 changed files
with
300 additions
and
6,436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,6 @@ target/ | |
# Vagrant | ||
.vagrant | ||
Vagrantfile | ||
|
||
# Node JS stuff | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,5 @@ var data_to_csv = function(data_set){ | |
return csv_string; | ||
|
||
} | ||
|
||
module.exports = data_to_csv; |
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Loads jQuery and all of the plugins we use. | ||
* | ||
* Since jQuery plugins work by modifying the global variable $, | ||
* we load up all of the plugins we use here so that we don't load | ||
* plugins multiple times. | ||
*/ | ||
|
||
var jQuery = require('jquery'); | ||
|
||
require('imports?$=jquery,jQuery=jquery!bootstrap'); | ||
require('imports?$=jquery,jQuery=jquery!bootstrap-validator'); | ||
require('imports?$=jquery,jQuery=jquery!jqueryfiletree/src/jQueryFileTree'); | ||
require('imports?$=jquery,jQuery=jquery!jquery-ui'); | ||
|
||
module.exports = jQuery; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.