From 3c5c13b764293aac3f66685464f2d364e7d6c670 Mon Sep 17 00:00:00 2001 From: Trevor Bekolay Date: Thu, 14 Jul 2016 13:48:42 -0400 Subject: [PATCH] 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/package.json b/package.json new file mode 100644 index 00000000..c8486191 --- /dev/null +++ b/package.json @@ -0,0 +1,37 @@ +{ + "name": "nengo", + "version": "0.2.1", + "description": "Frontend components for Nengo GUI", + "author": "Nengo developers", + "license": "Free for non-commercial use", + "main": "nengo_gui/static/dist/nengo.js", + "repository": { + "type": "git", + "url": "https://github.com/nengo/nengo_gui.git" + }, + "bugs": { + "url": "https://github.com/nengo/nengo_gui/issues" + }, + "private": true, + "scripts": { + "build": "webpack --debug --devtool source-map --output-pathinfo", + "release": "webpack --optimize-minimize --optimize-occurence-order" + }, + "devDependencies": { + "bootstrap": "^3.3.4", + "bootstrap-validator": "^0.8.1", + "brace": "^0.8.0", + "css-loader": "^0.23.1", + "d3": "^3.5.3", + "expose-loader": "^0.7.1", + "file-loader": "^0.9.0", + "imports-loader": "^0.6.5", + "interact.js": "^1.2.4", + "jquery": "^2.1.3", + "jquery-ui": "^1.10.4", + "jqueryfiletree": "jqueryfiletree/jqueryfiletree#2.1.4", + "style-loader": "^0.13.1", + "url-loader": "^0.5.7", + "webpack": "^1.13.1" + } +} diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 00000000..8ef9dcfd --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,41 @@ +var path = require('path'); +var webpack = require('webpack'); + +module.exports = { + context: __dirname, // Paths are relative to nengo_gui + // Putting the entry point in a list is a workaround for this error: + // Error: a dependency to an entry point is not allowed + entry: ['./nengo_gui/static/nengo.js'], + output: { + path: './nengo_gui/static/dist', + filename: 'nengo.js', + libraryTarget: 'var', + library: 'Nengo', + publicPath: '/static/dist/' // Fixes issue finding emitted files + }, + resolve: { + extensions: ['', '.js'] + }, + module: { + loaders: [ + { test: /\.css$/, loader: 'style-loader!css-loader' }, + { test: /\.ico$/, loader: 'file-loader?name=[name].[ext]' }, + { test: /\.(png|jpg|gif)$/, loader: 'url-loader?limit=8192' }, + { + test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, + loader: 'url-loader?limit=8192&mimetype=application/font-woff&name=./[hash].[ext]' + }, + { + test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, + loader: 'file-loader?name=./[hash].[ext]' + } + ] + }, + plugins: [ + new webpack.ProvidePlugin({ + $: 'jquery', + jQuery: 'jquery', + "window.jQuery": 'jquery', + }) + ] +}