From cb4522fa47d5e46312d53a62654f58c4a53c8cc2 Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Tue, 27 Dec 2016 15:15:39 -0200 Subject: Add webpack compilation to build, fix aliases, and add babel --- .gitignore | 1 + web-ui/package.json | 11 ++++++++--- web-ui/webpack.config.js | 25 ++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 0c347bf8..5bd72b2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea .bundle +*bundle.js *.log *.DS_Store *.egg-info diff --git a/web-ui/package.json b/web-ui/package.json index 5739dc29..8453d7e1 100644 --- a/web-ui/package.json +++ b/web-ui/package.json @@ -5,9 +5,13 @@ "repository": "https://github.com/pixelated-project/pixelated-user-agent", "private": true, "devDependencies": { + "babel": "^6.5.2", + "babel-core": "^6.21.0", + "babel-loader": "^6.2.10", + "babel-preset-es2015": "^6.18.0", "bower": "1.7.9", "dompurify": "^0.8.4", - "flight": "0.0.2", + "flightjs": "^1.5.1", "font-awesome": "^4.7.0", "foundation": "^4.2.1-1", "handlebars": "^4.0.5", @@ -40,7 +44,8 @@ "requirejs": "2.2.0", "typeahead.js": "^0.11.1", "utf8": "^2.1.2", - "watch": "0.19.1" + "watch": "0.19.1", + "webpack": "^1.14.0" }, "scripts": { "test": "npm run jshint --silent && npm run build --silent && karma start --single-run $GRUNT_OPTS", @@ -51,7 +56,7 @@ "handlebars-watch": "watch 'npm run handlebars' app/templates", "compass": "compass compile", "compass-watch": "compass watch", - "build": "npm run clean && npm run handlebars && npm run add_git_version && npm run compass", + "build": "npm run clean && npm run handlebars && webpack --colors --progress && npm run add_git_version && npm run compass", "jshint": "jshint --config=.jshintrc app test", "clean": "rm -rf .tmp/ 'dist/*' app/js/generated/hbs/* app/css/*", "buildmain": "node_modules/requirejs/bin/r.js -o config/buildoptions.js", diff --git a/web-ui/webpack.config.js b/web-ui/webpack.config.js index 230b50ea..39bdd511 100644 --- a/web-ui/webpack.config.js +++ b/web-ui/webpack.config.js @@ -1,12 +1,22 @@ var path = require('path') module.exports = { + entry: './app/js/index.js', + output: { + path: path.join(__dirname, '/app/js/'), + filename: 'bundle.js', + publicPath: '/assets/js/' + }, resolve: { alias: { + 'js': path.join(__dirname, '/app/js'), + 'flight': path.join(__dirname, '/app/bower_components/flight'), 'mail_list': path.join(__dirname, '/app/js/mail_list'), 'page': path.join(__dirname, '/app/js/page'), 'feedback': path.join(__dirname, '/app/js/feedback'), - 'DOMPurify': path.join(__dirname, '/app/bower_components/DOMPurify/dist/purify.min'), + 'DOMPurify': 'dompurify', + 'i18nextXHRBackend': 'i18next-xhr-backend', + 'i18nextBrowserLanguageDetector': 'i18next-browser-languagedetector', 'hbs': path.join(__dirname, '/app/js/generated/hbs'), 'helpers': path.join(__dirname, '/app/js/helpers'), 'lib': path.join(__dirname, '/app/js/lib'), @@ -23,7 +33,16 @@ module.exports = { 'features': path.join(__dirname, '/app/js/features/features'), 'user_settings': path.join(__dirname, '/app/js/user_settings') }, - extensions: ['', '.js'], - moduleDirectories: ['app/js'] + extensions: ['', '.js'] + }, + module: { + loaders: [ + { + test: /\.js$/, + exclude: /(node_modules|bower_components)/, + loader: 'babel', + query: { presets: ['es2015']} + } + ] } } -- cgit v1.2.3