diff --git a/client/react-native/mobile/android/app/build.gradle b/client/react-native/mobile/android/app/build.gradle index 5a39bbb62a..7245426e1a 100644 --- a/client/react-native/mobile/android/app/build.gradle +++ b/client/react-native/mobile/android/app/build.gradle @@ -96,7 +96,6 @@ def enableProguardInReleaseBuilds = false android { compileSdkVersion rootProject.ext.compileSdkVersion - buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { applicationId "com.berty" diff --git a/client/react-native/mobile/android/build.gradle b/client/react-native/mobile/android/build.gradle index 07ec1ca0f5..9bfe06d2ee 100644 --- a/client/react-native/mobile/android/build.gradle +++ b/client/react-native/mobile/android/build.gradle @@ -37,9 +37,8 @@ allprojects { } ext { - buildToolsVersion = "26.0.3" minSdkVersion = 16 - compileSdkVersion = 26 - targetSdkVersion = 26 - supportLibVersion = "26.1.0" + compileSdkVersion = 27 + targetSdkVersion = 27 + supportLibVersion = "27.1.1" } diff --git a/client/react-native/mobile/android/gradle.properties b/client/react-native/mobile/android/gradle.properties index 1fd964e90b..f00d01d742 100644 --- a/client/react-native/mobile/android/gradle.properties +++ b/client/react-native/mobile/android/gradle.properties @@ -18,3 +18,4 @@ # org.gradle.parallel=true android.useDeprecatedNdk=true +org.gradle.configureondemand=true diff --git a/client/react-native/web/config/webpack.config.prod.js b/client/react-native/web/config/webpack.config.prod.js index b2d0685dd0..5f70c03d73 100644 --- a/client/react-native/web/config/webpack.config.prod.js +++ b/client/react-native/web/config/webpack.config.prod.js @@ -2,24 +2,21 @@ const autoprefixer = require('autoprefixer') const path = require('path') const webpack = require('webpack') const HtmlWebpackPlugin = require('html-webpack-plugin') -const UglifyJsPlugin = require('uglifyjs-webpack-plugin') -const MiniCssExtractPlugin = require('mini-css-extract-plugin') -const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') +const ExtractTextPlugin = require('extract-text-webpack-plugin') const ManifestPlugin = require('webpack-manifest-plugin') const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin') const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin') +const eslintFormatter = require('react-dev-utils/eslintFormatter') const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin') -const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent') const paths = require('./paths') const getClientEnvironment = require('./env') -const fs = require('fs') -const babelrc = JSON.parse( - fs.readFileSync(path.resolve(__dirname, '../../.babelrc')) -) // Webpack uses `publicPath` to determine where the app is being served from. // It requires a trailing slash, or the file assets will get an incorrect path. const publicPath = paths.servedPath +// Some apps do not use client-side routing with pushState. +// For these, "homepage" can be set to "." to enable relative asset paths. +const shouldUseRelativeAssetPaths = publicPath === './' // Source maps are resource heavy and can cause out of memory issue for large source files. const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false' // `publicUrl` is just like `publicPath`, but we will provide it to our app @@ -35,55 +32,21 @@ if (env.stringified['process.env'].NODE_ENV !== '"production"') { throw new Error('Production builds must have NODE_ENV=production.') } -// style files regexes -const cssRegex = /\.css$/ -const cssModuleRegex = /\.module\.css$/ -const sassRegex = /\.(scss|sass)$/ -const sassModuleRegex = /\.module\.(scss|sass)$/ +// Note: defined here because it will be used more than once. +const cssFilename = 'static/css/[name].[contenthash:8].css' -// common function to get style loaders -const getStyleLoaders = (cssOptions, preProcessor) => { - const loaders = [ - MiniCssExtractPlugin.loader, - { - loader: require.resolve('css-loader'), - options: cssOptions, - }, - { - // Options for PostCSS as we reference these options twice - // Adds vendor prefixing based on your specified browser support in - // package.json - loader: require.resolve('postcss-loader'), - options: { - // Necessary for external CSS imports to work - // https://github.com/facebook/create-react-app/issues/2677 - ident: 'postcss', - plugins: () => [ - require('postcss-flexbugs-fixes'), - autoprefixer({ - flexbox: 'no-2009', - }), - ], - sourceMap: shouldUseSourceMap, - }, - }, - ] - if (preProcessor) { - loaders.push({ - loader: require.resolve(preProcessor), - options: { - sourceMap: shouldUseSourceMap, - }, - }) - } - return loaders -} +// ExtractTextPlugin expects the build output to be flat. +// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27) +// However, our output is structured with css, js and media folders. +// To have this structure working with relative paths, we have to use custom options. +const extractTextPluginOptions = shouldUseRelativeAssetPaths + ? { publicPath: Array(cssFilename.split('/').length).join('../') } // Making sure that the publicPath goes back to to build folder. + : {} // This is the production configuration. // It compiles slowly and is focused on producing a fast and minimal bundle. // The development configuration is different and lives in a separate file. module.exports = { - mode: 'production', // Don't attempt to continue if there are any errors. bail: true, // We generate sourcemaps in production. This is slow but gives good results. @@ -107,71 +70,19 @@ module.exports = { .relative(paths.appSrc, info.absoluteResourcePath) .replace(/\\/g, '/'), }, - optimization: { - minimizer: [ - new UglifyJsPlugin({ - uglifyOptions: { - parse: { - // we want uglify-js to parse ecma 8 code. However, we don't want it - // to apply any minfication steps that turns valid ecma 5 code - // into invalid ecma 5 code. This is why the 'compress' and 'output' - // sections only apply transformations that are ecma 5 safe - // https://github.com/facebook/create-react-app/pull/4234 - ecma: 8, - }, - compress: { - ecma: 5, - warnings: false, - // Disabled because of an issue with Uglify breaking seemingly valid code: - // https://github.com/facebook/create-react-app/issues/2376 - // Pending further investigation: - // https://github.com/mishoo/UglifyJS2/issues/2011 - comparisons: false, - }, - mangle: { - safari10: true, - }, - output: { - ecma: 5, - comments: false, - // Turned on because emoji and regex is not minified properly using default - // https://github.com/facebook/create-react-app/issues/2488 - ascii_only: true, - }, - }, - // Use multi-process parallel running to improve the build speed - // Default number of concurrent runs: os.cpus().length - 1 - parallel: true, - // Enable file caching - cache: true, - sourceMap: shouldUseSourceMap, - }), - new OptimizeCSSAssetsPlugin(), - ], - // Automatically split vendor and commons - // https://twitter.com/wSokra/status/969633336732905474 - // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366 - splitChunks: { - chunks: 'all', - name: 'vendors', - }, - // Keep the runtime chunk seperated to enable long term caching - // https://twitter.com/wSokra/status/969679223278505985 - runtimeChunk: true, - }, resolve: { // This allows you to set a fallback for where Webpack should look for modules. // We placed these paths second because we want `node_modules` to "win" // if there are any conflicts. This matches Node resolution mechanism. - // https://github.com/facebook/create-react-app/issues/253 - modules: ['node_modules'].concat( + // https://github.com/facebookincubator/create-react-app/issues/253 + modules: ['node_modules', paths.appNodeModules].concat( // It is guaranteed to exist because we tweak it in `env.js` process.env.NODE_PATH.split(path.delimiter).filter(Boolean) ), // These are the reasonable defaults supported by the Node ecosystem. // We also include JSX as a common component filename extension to support // some tools, although we do not recommend using it, see: - // https://github.com/facebook/create-react-app/issues/290 + // https://github.com/facebookincubator/create-react-app/issues/290 // `web` extension prefixes have been added for better support // for React Native Web. extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'], @@ -192,8 +103,9 @@ module.exports = { module: { strictExportPresence: true, rules: [ - // Disable require.ensure as it's not a standard language feature. - { parser: { requireEnsure: false } }, + // TODO: Disable require.ensure as it's not a standard language feature. + // We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176. + // { parser: { requireEnsure: false } }, // First, run the linter. // It's important to do this before Babel processes the JS. @@ -202,13 +114,15 @@ module.exports = { enforce: 'pre', use: [ { + options: { + formatter: eslintFormatter, + eslintPath: require.resolve('eslint'), + }, loader: require.resolve('eslint-loader'), }, ], - include: paths.srcPaths, - exclude: [/[/\\\\]node_modules[/\\\\]/], + include: paths.appSrc, }, - { // "oneOf" will traverse all following loaders until one will // match the requirements. When no loader matches it will fall @@ -224,111 +138,87 @@ module.exports = { name: 'static/media/[name].[hash:8].[ext]', }, }, - { - test: /\.ttf$/, - loader: 'url-loader', // or directly file-loader - include: require.resolve('react-native-vector-icons'), - }, - // Process application JS with Babel. - // The preset includes JSX, Flow, and some ESnext features. + // Process JS with Babel. { test: /\.(js|jsx|mjs)$/, - include: paths.srcPaths, + include: paths.appSrc, exclude: [/[/\\\\]node_modules[/\\\\]/], - use: [ - // This loader parallelizes code compilation, it is optional but - // improves compile time on larger projects - require.resolve('thread-loader'), - { - loader: require.resolve('babel-loader'), - options: { - compact: true, - highlightCode: true, - ...babelrc, - }, - }, - ], + loader: require.resolve('babel-loader'), + options: { + compact: true, + }, }, // Process any JS outside of the app with Babel. // Unlike the application JS, we only compile the standard ES features. { test: /\.js$/, - use: [ - // This loader parallelizes code compilation, it is optional but - // improves compile time on larger projects - require.resolve('thread-loader'), - { - loader: require.resolve('babel-loader'), - options: { - babelrc: false, - compact: false, - presets: [ - require.resolve('babel-preset-react-app/dependencies'), - ], - cacheDirectory: true, - highlightCode: true, - }, - }, - ], + loader: require.resolve('babel-loader'), + options: { + babelrc: false, + compact: false, + presets: [require.resolve('babel-preset-react-app')], + cacheDirectory: true, + highlightCode: true, + }, }, + // The notation here is somewhat confusing. // "postcss" loader applies autoprefixer to our CSS. // "css" loader resolves paths in CSS and adds assets as dependencies. - // `MiniCSSExtractPlugin` extracts styles into CSS - // files. If you use code splitting, async bundles will have their own separate CSS chunk file. - // By default we support CSS Modules with the extension .module.css - { - test: cssRegex, - exclude: cssModuleRegex, - loader: getStyleLoaders({ - importLoaders: 1, - sourceMap: shouldUseSourceMap, - }), - }, - // Adds support for CSS Modules (https://github.com/css-modules/css-modules) - // using the extension .module.css - { - test: cssModuleRegex, - loader: getStyleLoaders({ - importLoaders: 1, - sourceMap: shouldUseSourceMap, - modules: true, - getLocalIdent: getCSSModuleLocalIdent, - }), - }, - // Opt-in support for SASS. The logic here is somewhat similar - // as in the CSS routine, except that "sass-loader" runs first - // to compile SASS files into CSS. - // By default we support SASS Modules with the - // extensions .module.scss or .module.sass + // "style" loader normally turns CSS into JS modules injecting