summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnike Arni <aarni@thoughtworks.com>2016-12-28 17:51:54 -0200
committerAnike Arni <aarni@thoughtworks.com>2016-12-28 17:51:54 -0200
commitee97dee72ec1673ad18fe86855b1e1aceabba674 (patch)
treee337e6bce3fcd77fd4d953d5cc6f44ab7e2b2188
parent93cec7cbc6c03b2bd95b1e031e894327bdaa65b4 (diff)
Use webpack files for packaging
-rw-r--r--web-ui/config/package.sh24
-rw-r--r--web-ui/package.json6
-rw-r--r--web-ui/webpack.config.js1
-rw-r--r--web-ui/webpack.production.config.js111
4 files changed, 117 insertions, 25 deletions
diff --git a/web-ui/config/package.sh b/web-ui/config/package.sh
index 4eb11929..cfb66879 100644
--- a/web-ui/config/package.sh
+++ b/web-ui/config/package.sh
@@ -23,33 +23,11 @@ export PIXELATED_BUILD='package'
mkdir -p dist
# initial npm tasks
-./go build
+./go build-prod
./go imagemin
-./go minify_html
./go minify_sandbox
-# concat js files and minify for app.min.js
-cat \
-app/bower_components/modernizr/modernizr.js \
-app/bower_components/lodash/dist/lodash.js \
-app/bower_components/jquery/dist/jquery.js \
-app/bower_components/jquery-ui/jquery-ui.js \
-app/bower_components/jquery-file-upload/js/jquery.fileupload.js \
-app/bower_components/handlebars/handlebars.js \
-app/bower_components/typeahead.js/dist/typeahead.bundle.js \
-app/bower_components/iframe-resizer/js/iframeResizer.js \
-app/js/1.bundle.js \
-app/js/bundle.js > dist/app.js
-node_modules/.bin/minify dist/app.js > dist/app.min.js
-rm dist/app.js
-
-if [ ! -s dist/app.min.js ]
-then
-echo "Minification failed!"
-exit 1;
-fi
-
# concat js files and minify for sandbox.min.js
cat \
app/js/sandbox.js \
diff --git a/web-ui/package.json b/web-ui/package.json
index 728699e6..6405102b 100644
--- a/web-ui/package.json
+++ b/web-ui/package.json
@@ -37,6 +37,7 @@
"karma-junit-reporter": "0.2.2",
"karma-phantomjs-launcher": "1.0.1",
"karma-requirejs": "1.0.0",
+ "minify": "^2.0.13",
"modernizr": "^3.3.1",
"quoted-printable": "^1.0.1",
"requirejs": "2.2.0",
@@ -54,14 +55,15 @@
"handlebars-watch": "watch 'npm run handlebars' app/templates",
"compass": "compass compile",
"compass-watch": "compass watch",
- "build": "npm run clean && npm run handlebars && npm run build-js && npm run add_git_version && npm run compass",
+ "build": "npm run build-statics && npm run build-js",
+ "build-statics": "npm run clean && npm run handlebars && npm run add_git_version && npm run compass",
+ "build-prod": "npm run build-statics && webpack -p --config ./webpack.production.config.js",
"build-js": "webpack --colors --progress",
"jshint": "jshint --config=.jshintrc app test",
"clean": "rm -rf 'dist/*' app/js/generated/hbs/* app/css/*",
"buildmain": "node_modules/requirejs/bin/r.js -o config/buildoptions.js",
"package": "/bin/bash config/package.sh",
"imagemin": "node config/imagemin.js",
- "minify_html": "html-minifier app/index.html --collapse-whitespace | sed 's|<!--usemin_start-->.*<!--usemin_end-->|<script src=\"assets/app.min.js\" type=\"text/javascript\"></script>|' > dist/index.html",
"minify_sandbox": "html-minifier app/sandbox.html --collapse-whitespace | sed 's|<!--usemin_start-->.*<!--usemin_end-->|<script src=\"sandbox.min.js\" type=\"text/javascript\"></script>|' > dist/sandbox.html",
"add_git_version": "/bin/bash config/add_git_version.sh"
}
diff --git a/web-ui/webpack.config.js b/web-ui/webpack.config.js
index 1ab036c6..c4a54b4a 100644
--- a/web-ui/webpack.config.js
+++ b/web-ui/webpack.config.js
@@ -51,6 +51,7 @@ module.exports = {
plugins: [
new CopyWebpackPlugin([
{ context: 'app/', from: '404.html' },
+ { context: 'app/', from: 'index.html' },
{ context: 'app/', from: 'fonts/*' },
{ context: 'app/', from: 'locales/**/*' },
{ context: 'app/', from: 'bower_components/font-awesome/fonts/*' },
diff --git a/web-ui/webpack.production.config.js b/web-ui/webpack.production.config.js
new file mode 100644
index 00000000..36eb9396
--- /dev/null
+++ b/web-ui/webpack.production.config.js
@@ -0,0 +1,111 @@
+var path = require('path');
+var webpack = require('webpack');
+var CopyWebpackPlugin = require('copy-webpack-plugin');
+
+module.exports = {
+ entry: './app/js/index.js',
+ node: { fs: 'empty' },
+ output: {
+ path: path.join(__dirname, '/dist/'),
+ filename: 'app.min.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': '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'),
+ 'views': path.join(__dirname, '/app/js/views'),
+ 'tags': path.join(__dirname, '/app/js/tags'),
+ 'mail_list_actions': path.join(__dirname, '/app/js/mail_list_actions'),
+ 'user_alerts': path.join(__dirname, '/app/js/user_alerts'),
+ 'mail_view': path.join(__dirname, '/app/js/mail_view'),
+ 'dispatchers': path.join(__dirname, '/app/js/dispatchers'),
+ 'services': path.join(__dirname, '/app/js/services'),
+ 'mixins': path.join(__dirname, '/app/js/mixins'),
+ 'search': path.join(__dirname, '/app/js/search'),
+ 'foundation': path.join(__dirname, '/app/js/foundation'),
+ 'features': path.join(__dirname, '/app/js/features/features'),
+ 'user_settings': path.join(__dirname, '/app/js/user_settings')
+ },
+ extensions: ['', '.js']
+ },
+ module: {
+ loaders: [
+ {
+ test: /\.js$/,
+ loader: 'babel',
+ query: { presets: ['es2015']}
+ }
+ ]
+ },
+ plugins: [
+ new webpack.optimize.UglifyJsPlugin(),
+ new webpack.optimize.DedupePlugin(),
+ new CopyWebpackPlugin([
+ { context: 'app/', from: '404.html' },
+ { context: 'app/', from: 'index.html' },
+ { context: 'app/', from: 'fonts/*' },
+ { context: 'app/', from: 'locales/**/*' },
+ { context: 'app/', from: 'bower_components/font-awesome/fonts/*' },
+ {
+ context: 'app/',
+ from: 'bower_components/font-awesome/css/font-awesome.min.css',
+ to: 'bower_components/font-awesome/css'
+ },
+ {
+ context: 'app/',
+ from: 'bower_components/jquery-file-upload/css/jquery.fileupload.css',
+ to: 'bower_components/jquery-file-upload/css'
+ },
+ {
+ context: 'app/',
+ from: 'bower_components/modernizr/modernizr.js',
+ to: 'bower_components/modernizr'
+ },
+ {
+ context: 'app/',
+ from: 'bower_components/lodash/dist/lodash.min.js',
+ to: 'bower_components/lodash/dist'
+ },
+ {
+ context: 'app/',
+ from: 'bower_components/jquery/dist/jquery.min.js',
+ to: 'bower_components/jquery/dist'
+ },
+ {
+ context: 'app/',
+ from: 'bower_components/jquery-ui/jquery-ui.min.js',
+ to: 'bower_components/jquery-ui'
+ },
+ {
+ context: 'app/',
+ from: 'bower_components/jquery-file-upload/js/jquery.fileupload.js',
+ to: 'bower_components/jquery-file-upload/js'
+ },
+ {
+ context: 'app/',
+ from: 'bower_components/handlebars/handlebars.min.js',
+ to: 'bower_components/handlebars'
+ },
+ {
+ context: 'app/',
+ from: 'bower_components/typeahead.js/dist/typeahead.bundle.min.js',
+ to: 'bower_components/typeahead.js/dist'
+ },
+ {
+ context: 'app/',
+ from: 'bower_components/iframe-resizer/js/iframeResizer.min.js',
+ to: 'bower_components/iframe-resizer/js'
+ }
+ ])
+ ]
+}