Commit 01f82c64 authored by Eric Eastwood's avatar Eric Eastwood

Move Android/iOS webpack builds into the main config

parent 6ce4a60b
......@@ -31,26 +31,7 @@ gulp.task('clientapp:compile:copy-files', function() {
gulp.task('clientapp:compile:webpack', ['clientapp:compile:copy-files'], function() {
return gulp
.src('./public/js/webpack.config')
.pipe(
webpack(require('../public/js/webpack.config'), null, function(err, stats) {
if (!stats) return;
/*
Removed as webpack-bundle-size-analyzer is broken
var webpackBundleSizeAnalyzer = require('webpack-bundle-size-analyzer');
var bundleStats = stats.toJson("normal");
var depTrees = webpackBundleSizeAnalyzer.dependencySizeTree(bundleStats);
gutil.log('-----------------------------------------------');
gutil.log('Webpack Bundle Size Report');
gutil.log('-----------------------------------------------');
depTrees.forEach(function (tree) {
return webpackBundleSizeAnalyzer.printDependencySizeTree(tree);
});
gutil.log('-----------------------------------------------');
*/
})
)
.pipe(webpack(require('../public/js/webpack.config')))
.pipe(gulp.dest('output/assets/js'));
});
......
......@@ -10,10 +10,13 @@ const mqpacker = require('css-mqpacker');
const csswring = require('csswring');
const styleBuilder = require('./style-builder');
const getSourceMapOptions = require('./get-sourcemap-options');
const webpack = require('webpack-stream');
const uglify = require('gulp-uglify');
const childProcessPromise = require('./child-process-promise');
const extractUrls = require('./extract-urls');
const bootScriptUtils = require('gitter-web-templates/lib/boot-script-utils');
// We need access to the `clientapp:compile:webpack` task
require('./gulpfile-clientapp');
var opts = require('yargs')
.option('android', {
......@@ -42,14 +45,14 @@ if (opts.android) {
* Hook into the compile stage
*/
gulp.task('embedded:compile', [
'clientapp:compile:copy-files',
'embedded:compile:copy-files',
'embedded:compile:markup',
'embedded:compile:css',
'embedded:compile:webpack'
'embedded:compile:copy-webpack-builds'
]);
// We also copy files after the CSS is compiled in `embedded:post-compile:copy-linked-assets`
gulp.task('clientapp:compile:copy-files', function() {
gulp.task('embedded:compile:copy-files', function() {
return gulp
.src(
[
......@@ -117,10 +120,14 @@ gulp.task('embedded:compile:css', function() {
});
/* Generate embedded native */
gulp.task('embedded:compile:webpack', ['clientapp:compile:copy-files'], function() {
gulp.task('embedded:compile:copy-webpack-builds', ['clientapp:compile:webpack'], function() {
const assets = bootScriptUtils.generateAssetsForChunk('mobile-native-embedded-chat');
return gulp
.src('./public/js/webpack-mobile-native.config')
.pipe(webpack(require('../public/js/webpack-mobile-native.config')))
.src(assets.map(asset => path.join('output/assets/js/', asset)), {
base: './output/assets/js/',
stat: true
})
.pipe(gulp.dest(path.join(buildPath, 'js')));
});
......
......@@ -7,56 +7,12 @@ var clientEnv = require('gitter-client-env');
var cdn = require('gitter-web-cdn');
var pluralize = require('../shared/helpers/pluralize');
var when = require('../shared/helpers/when');
// eslint-disable-next-line node/no-unpublished-require, node/no-missing-require
const webpackBuildManifest = require('../../../output/assets/js/webpack-manifest.json');
const bootScriptUtils = require('./boot-script-utils');
function cdnHelper(url, parameters) {
return cdn(url, parameters ? parameters.hash : null);
}
function cdnUrlGenerator(url, options = {}) {
if (options.root) {
return options.root + url;
}
return cdn(url, {});
}
function generateAssetsForChunk(chunkName) {
const defaultAssets = webpackBuildManifest.entrypoints.default.assets || [];
const entryAssets = webpackBuildManifest.entrypoints[chunkName].assets;
const assets = Object.keys(
defaultAssets
.concat(entryAssets)
.filter(asset => !/.*\.map$/.test(asset))
.reduce((assetMap, asset) => {
assetMap[asset] = true;
return assetMap;
}, {})
);
return assets;
}
const bootScript = _.memoize(function(chunkName, parameters) {
const options = parameters.hash;
const jsRoot = (options && options.jsRoot) || 'js';
const assets = generateAssetsForChunk(chunkName);
const baseUrl = cdnUrlGenerator(jsRoot + '/', options);
const chunkScriptList = assets.map(asset => {
const cdnUrl = cdnUrlGenerator(`${jsRoot}/${asset}`, options);
return `<script type="text/javascript" src="${cdnUrl}"></script>`;
});
return `
<script type="text/javascript">window.webpackPublicPath = '${baseUrl}';</script>
${chunkScriptList.join('\n')}
`;
});
function createEnv(context, options) {
if (options) {
return _.extend(
......@@ -163,7 +119,7 @@ function getRoomName(name) {
module.exports = {
cdn: cdnHelper,
bootScript,
bootScript: bootScriptUtils.bootScriptHelper,
generateEnv,
generateTroupeContext,
pluralize,
......
'use strict';
var path = require('path');
var _ = require('lodash');
var mainWebpackConfig = require('./webpack.config');
var mobileConfig = _.extend({}, mainWebpackConfig);
mobileConfig.entry = {
'mobile-native-embedded-chat': path.resolve(
path.join(__dirname, './mobile-native-embedded-chat')
),
vendor: mainWebpackConfig.entry.vendor
};
mobileConfig.plugins = mobileConfig.plugins.slice();
module.exports = mobileConfig;
......@@ -46,6 +46,9 @@ const webpackConfig = {
'chat-message-reports': path.resolve(path.join(__dirname, './chat-message-reports.js')),
'mobile-native-userhome': path.resolve(path.join(__dirname, './mobile-native-userhome')),
'mobile-native-embedded-chat': path.resolve(
path.join(__dirname, './mobile-native-embedded-chat')
),
'router-home-learn': path.resolve(path.join(__dirname, './router-home-learn'))
},
output: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment