diff --git a/.env.example b/.env.example index 5d0c1fa6..cb172be8 100644 --- a/.env.example +++ b/.env.example @@ -9,6 +9,8 @@ REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET= # For all environments REACT_APP_INFURA_TOKEN= +REACT_APP_IPFS_GATEWAY=https://ipfs.io/ipfs +PUBLIC_URL=/app/ # For production environments REACT_APP_BLOCKNATIVE_KEY= @@ -28,4 +30,3 @@ REACT_APP_APP_VERSION=$npm_package_version # For Apps REACT_APP_GNOSIS_APPS_URL=https://safe-apps.staging.gnosisdev.com -REACT_APP_APPS_DISABLED=false diff --git a/.eslintignore b/.eslintignore index d19b22ed..c2ffcb25 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,5 @@ !.eslintrc.js -build_webpack +build config contracts flow-typed diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 28b650c1..00000000 --- a/.eslintrc +++ /dev/null @@ -1,112 +0,0 @@ -{ - "settings": { - "react": { - "flowVersion": "0.112.0", - "pragma": "React", - "version": "16.12.0" - }, - "import/extensions": [".js", ".jsx"] - }, - "parser": "babel-eslint", - "plugins": ["react", "flowtype", "import", "jsx-a11y", "sort-destructure-keys", "prettier"], - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:flowtype/recommended", - "plugin:import/errors", - "plugin:import/warnings", - "plugin:jsx-a11y/recommended", - "plugin:prettier/recommended", - "prettier/react", - "prettier/flowtype" - ], - "parserOptions": { - "ecmaFeatures": { - "jsx": true - } - }, - "env": { - "browser": true, - "amd": true, - "node": true, - "es6": true - }, - "rules": { - "class-methods-use-this": 0, - "max-len": [ - "error", - 120, - 2, - { - "ignoreComments": false, - "ignoreRegExpLiterals": true, - "ignoreStrings": true, - "ignoreTemplateLiterals": true, - "ignoreUrls": true - } - ], - "no-console": [ - "error", - { - "allow": ["warn", "error"] - } - ], - "semi": ["error", "never"], - "sort-imports": [ - "error", - { - "ignoreDeclarationSort": true - } - ], - "flowtype/require-valid-file-annotation": [ - 2, - "always", - { - "annotationStyle": "line" - } - ], - "import/extensions": 0, - "import/no-extraneous-dependencies": 0, - "import/no-unresolved": 0, - "import/order": [ - "error", - { - "groups": ["builtin", "external", "parent", "sibling", "index"], - "newlines-between": "always", - "alphabetize": { - "order": "asc" - } - } - ], - "import/prefer-default-export": 0, - "jsx-a11y/anchor-is-valid": [ - "error", - { - "components": ["Link"], - "specialLink": ["to", "hrefLeft", "hrefRight"], - "aspects": ["noHref", "invalidHref", "preferButton"] - } - ], - "react/default-props-match-prop-types": ["error", { "allowRequiredDefaults": true }], - "react/forbid-prop-types": [ - 1, - { - "forbid": ["object", "any"] - } - ], - "react/no-array-index-key": 0, - "react/require-default-props": 0, - "react/state-in-constructor": 0, - "react/jsx-filename-extension": [ - 1, - { - "extensions": [".js", ".jsx"] - } - ], - "react/jsx-props-no-spreading": 0, - "react/jsx-sort-props": 2, - "prettier/prettier": "error", - "jsx-a11y/no-autofocus": "warn", - "sort-destructure-keys/sort-destructure-keys": 2 - } -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..764f17bc --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,33 @@ +module.exports = { + parser: '@typescript-eslint/parser', + extends: [ + 'plugin:react/recommended', + 'plugin:@typescript-eslint/recommended', + 'prettier/@typescript-eslint', + 'plugin:prettier/recommended', + ], + plugins: ['react-hooks'], + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + ecmaFeatures: { + jsx: true, + }, + }, + rules: { + 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'warn', + 'react/prop-types': 'off', + '@typescript-eslint/camelcase': 'off', + '@typescript-eslint/no-var-requires': 'off', + '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }], + }, + settings: { + react: { + version: 'detect', + }, + }, +} diff --git a/.flowconfig b/.flowconfig deleted file mode 100644 index c95da88a..00000000 --- a/.flowconfig +++ /dev/null @@ -1,36 +0,0 @@ -[ignore] -/migrations/**/.* -/contracts/**/.* -/scripts/**/.* -/public/**/.* -/babel.config.js -/jest.config.js -/truffle.js - -[untyped] -/config/**/.* - -[declarations] -/node_modules/**/.* -/flow-typed/**/.* - -[include] -/src/**/.* - -[libs] -/flow-typed/**/.* - -[lints] - -[options] -module.file_ext=.js -module.file_ext=.json -module.file_ext=.jsx -module.file_ext=.css -module.file_ext=.scss - -module.name_mapper='^~' ->'/src' -module.name_mapper='^#' ->'/safe-contracts/build/contracts' -module.name_mapper='.*\(.s?css\)' -> '{}' - -[strict] \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64ab87f5..84954364 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,9 @@ name: Build/Release Desktop app # this will help you specify where to run on: push: - branches: - # this will run on the specified branch - - master - - development + branches-ignore: + # Temporary disable action + - '**' env: REACT_APP_BLOCKNATIVE_KEY: ${{ secrets.REACT_APP_BLOCKNATIVE_KEY }} diff --git a/.gitignore b/.gitignore index f83c31b4..78cf7778 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ node_modules/ -build_webpack/ +build/ .DS_Store -./build yarn-error.log .env* .idea/ diff --git a/.prettierignore b/.prettierignore index d19b22ed..c2ffcb25 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,5 @@ !.eslintrc.js -build_webpack +build config contracts flow-typed diff --git a/.travis.yml b/.travis.yml index f907cbe5..89a975e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ services: - docker language: node_js node_js: - - "10" + - '10' os: - linux env: @@ -13,18 +13,20 @@ env: - DOCKER_COMPOSE_VERSION=1.22.0 matrix: include: - - env: - - REACT_APP_NETWORK='mainnet' - - STAGING_BUCKET_NAME=${STAGING_MAINNET_BUCKET_NAME} - - REACT_APP_GNOSIS_APPS_URL=${REACT_APP_GNOSIS_APPS_URL_PROD} - if: (branch = master AND NOT type = pull_request) OR tag IS present - - env: - - REACT_APP_NETWORK='rinkeby' - - REACT_APP_GNOSIS_APPS_URL=${REACT_APP_GNOSIS_APPS_URL_STAGING} + - env: + - REACT_APP_NETWORK='mainnet' + - STAGING_BUCKET_NAME=${STAGING_MAINNET_BUCKET_NAME} + - REACT_APP_GNOSIS_APPS_URL=${REACT_APP_GNOSIS_APPS_URL_PROD} + if: (branch = master AND NOT type = pull_request) OR tag IS present + - env: + - REACT_APP_NETWORK='rinkeby' + - REACT_APP_GNOSIS_APPS_URL=${REACT_APP_GNOSIS_APPS_URL_STAGING} +cache: + yarn: true before_install: # Needed to deploy pull request and releases - sudo apt-get update - - sudo apt-get -y install python-pip python-dev + - sudo apt-get -y install python-pip python-dev libusb-1.0-0-dev - pip install awscli --upgrade --user # Install truffle - yarn global add truffle @@ -39,41 +41,41 @@ after_success: deploy: # Development environment -- provider: s3 - bucket: $DEV_BUCKET_NAME - access_key_id: $AWS_ACCESS_KEY_ID - secret_access_key: $AWS_SECRET_ACCESS_KEY - skip_cleanup: true - local_dir: build_webpack - upload-dir: app - region: $AWS_DEFAULT_REGION - on: - branch: development + - provider: s3 + bucket: $DEV_BUCKET_NAME + access_key_id: $AWS_ACCESS_KEY_ID + secret_access_key: $AWS_SECRET_ACCESS_KEY + skip_cleanup: true + local_dir: build + upload-dir: app + region: $AWS_DEFAULT_REGION + on: + branch: development - # Staging environment -- provider: s3 - bucket: $STAGING_BUCKET_NAME - access_key_id: $AWS_ACCESS_KEY_ID - secret_access_key: $AWS_SECRET_ACCESS_KEY - skip_cleanup: true - local_dir: build_webpack - upload-dir: current/app - region: $AWS_DEFAULT_REGION - on: - branch: master + # Staging environment + - provider: s3 + bucket: $STAGING_BUCKET_NAME + access_key_id: $AWS_ACCESS_KEY_ID + secret_access_key: $AWS_SECRET_ACCESS_KEY + skip_cleanup: true + local_dir: build + upload-dir: current/app + region: $AWS_DEFAULT_REGION + on: + branch: master - # Prepare production deployment -- provider: s3 - bucket: $STAGING_BUCKET_NAME - secret_access_key: $AWS_SECRET_ACCESS_KEY - access_key_id: $AWS_ACCESS_KEY_ID - skip_cleanup: true - local_dir: build_webpack - upload-dir: releases/$TRAVIS_TAG - region: $AWS_DEFAULT_REGION - on: - tags: true -- provider: script - script: ./config/travis/prepare_production_deployment.sh - on: - tags: true + # Prepare production deployment + - provider: s3 + bucket: $STAGING_BUCKET_NAME + secret_access_key: $AWS_SECRET_ACCESS_KEY + access_key_id: $AWS_ACCESS_KEY_ID + skip_cleanup: true + local_dir: build + upload-dir: releases/$TRAVIS_TAG + region: $AWS_DEFAULT_REGION + on: + tags: true + - provider: script + script: ./config/travis/prepare_production_deployment.sh + on: + tags: true diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index a5da135e..00000000 --- a/babel.config.js +++ /dev/null @@ -1,49 +0,0 @@ -// @flow -module.exports = { - presets: [ - '@babel/react', - '@babel/preset-flow', - [ - '@babel/env', - { - forceAllTransforms: true, - }, - ], - ], - plugins: [ - 'react-hot-loader/babel', - '@babel/plugin-syntax-dynamic-import', - '@babel/plugin-transform-member-expression-literals', - '@babel/plugin-transform-property-literals', - '@babel/plugin-syntax-import-meta', - '@babel/plugin-proposal-class-properties', - '@babel/plugin-proposal-json-strings', - [ - '@babel/plugin-proposal-decorators', - { - legacy: true, - }, - ], - '@babel/plugin-proposal-function-sent', - '@babel/plugin-proposal-export-namespace-from', - '@babel/plugin-proposal-numeric-separator', - '@babel/plugin-proposal-throw-expressions', - '@babel/plugin-proposal-export-default-from', - '@babel/plugin-proposal-logical-assignment-operators', - '@babel/plugin-proposal-optional-chaining', - [ - '@babel/plugin-proposal-pipeline-operator', - { - proposal: 'minimal', - }, - ], - '@babel/plugin-proposal-nullish-coalescing-operator', - '@babel/plugin-proposal-do-expressions', - '@babel/plugin-proposal-function-bind', - ], - env: { - test: { - plugins: ['dynamic-import-node'], - }, - }, -} diff --git a/config-overrides.js b/config-overrides.js new file mode 100644 index 00000000..35889ebf --- /dev/null +++ b/config-overrides.js @@ -0,0 +1,14 @@ +const webpack = require('webpack') + +module.exports = function override(config) { + if (!config.plugins) { + config.plugins = [] + } + config.plugins.push( + new webpack.ContextReplacementPlugin(/\/truffle-(contract|interface-adapter)\//, (data) => { + delete data.dependencies[0].critical + return data + }), + ) + return config +} diff --git a/config/env.js b/config/env.js deleted file mode 100644 index 7ed7d2c1..00000000 --- a/config/env.js +++ /dev/null @@ -1,29 +0,0 @@ -// @flow -// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be -// injected into the application via DefinePlugin in Webpack configuration. - -const REACT_APP = /^REACT_APP_/i - -function getClientEnvironment(publicUrl) { - const processEnv = Object.keys(process.env) - .filter((key) => REACT_APP.test(key)) - .reduce( - (env, key) => { - env[key] = JSON.stringify(process.env[key]) - return env - }, - { - // Useful for determining whether we’re running in production mode. - // Most importantly, it switches React into the correct mode. - NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development'), - // Useful for resolving the correct path to static assets in `public`. - // For example, . - // This should only be used as an escape hatch. Normally you would put - // images into the `src` and `import` them in code to get their paths. - PUBLIC_URL: JSON.stringify(publicUrl), - }, - ) - return { 'process.env': processEnv } -} - -module.exports = getClientEnvironment diff --git a/config/jest/LocalStorageMock.js b/config/jest/LocalStorageMock.js index 787ab7f2..45637cca 100644 --- a/config/jest/LocalStorageMock.js +++ b/config/jest/LocalStorageMock.js @@ -1,6 +1,5 @@ -// @flow class LocalStorageMock { - store: Object + store constructor() { this.store = {} diff --git a/config/jest/Web3Mock.js b/config/jest/Web3Mock.js index 87a55856..1c88c8ee 100644 --- a/config/jest/Web3Mock.js +++ b/config/jest/Web3Mock.js @@ -1,4 +1,3 @@ -// @flow import Web3 from 'web3' const window = global.window || {} diff --git a/config/jest/cssTransform.js b/config/jest/cssTransform.js index 05ec203f..b316fa67 100644 --- a/config/jest/cssTransform.js +++ b/config/jest/cssTransform.js @@ -1,4 +1,3 @@ -// @flow // This is a custom Jest transformer turning style imports into empty objects. // http://facebook.github.io/jest/docs/tutorial-webpack.html diff --git a/config/jest/fileTransform.js b/config/jest/fileTransform.js index 06760aa5..75969015 100644 --- a/config/jest/fileTransform.js +++ b/config/jest/fileTransform.js @@ -1,4 +1,3 @@ -// @flow const path = require('path') // This is a custom Jest transformer turning file imports into filenames. diff --git a/config/jest/jest.setup.js b/config/jest/jest.setup.js index 70a90313..7f0aedda 100644 --- a/config/jest/jest.setup.js +++ b/config/jest/jest.setup.js @@ -1,2 +1 @@ -// @flow jest.setTimeout(60000) diff --git a/config/paths.js b/config/paths.js deleted file mode 100644 index e964a29a..00000000 --- a/config/paths.js +++ /dev/null @@ -1,47 +0,0 @@ -var path = require('path'); -var fs = require('fs'); - -// Make sure any symlinks in the project folder are resolved: -// https://github.com/facebookincubator/create-react-app/issues/637 -var appDirectory = fs.realpathSync(process.cwd()); -function resolveApp(relativePath) { - return path.resolve(appDirectory, relativePath); -} - -// We support resolving modules according to `NODE_PATH`. -// This lets you use absolute paths in imports inside large monorepos: -// https://github.com/facebookincubator/create-react-app/issues/253. - -// It works similar to `NODE_PATH` in Node itself: -// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders - -// We will export `nodePaths` as an array of absolute paths. -// It will then be used by Webpack configs. -// Jest doesn’t need this because it already handles `NODE_PATH` out of the box. - -// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. -// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. -// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 - -var nodePaths = (process.env.NODE_PATH || '') - .split(process.platform === 'win32' ? ';' : ':') - .filter(Boolean) - .filter(folder => !path.isAbsolute(folder)) - .map(resolveApp); - -// config after eject: we're in ./config/ -module.exports = { - // Changed from build to build_webpack so smart contract compilations are not overwritten. - appBuild: resolveApp('build_webpack'), - appPublic: resolveApp('public'), - appHtml: resolveApp('public/index.html'), - appIndexJs: resolveApp('src/index.js'), - appPackageJson: resolveApp('package.json'), - appSrc: resolveApp('src'), - appContracts: resolveApp('safe-contracts/build/contracts'), - yarnLockFile: resolveApp('yarn.lock'), - testsSetup: resolveApp('src/setupTests.js'), - appNodeModules: resolveApp('node_modules'), - ownNodeModules: resolveApp('node_modules'), - nodePaths: nodePaths -}; diff --git a/config/polyfills.js b/config/polyfills.js deleted file mode 100644 index 4da409ab..00000000 --- a/config/polyfills.js +++ /dev/null @@ -1,15 +0,0 @@ -// @flow -if (typeof Promise === 'undefined') { - // Rejection tracking prevents a common issue where React gets into an - // inconsistent state due to an error, but it gets swallowed by a Promise, - // and the user has no idea what causes React's erratic future behavior. - require('promise/lib/rejection-tracking').enable() - window.Promise = require('promise/lib/es6-extensions.js') -} - -// fetch() polyfill for making API calls. -require('whatwg-fetch') - -// Object.assign() is commonly used with React. -// It will use the native implementation if it's present and isn't buggy. -Object.assign = require('object-assign') diff --git a/config/travis/deploy_pull_request.sh b/config/travis/deploy_pull_request.sh index fa285678..ca0e155d 100755 --- a/config/travis/deploy_pull_request.sh +++ b/config/travis/deploy_pull_request.sh @@ -15,7 +15,7 @@ function deploy_pull_request { REVIEW_FEATURE_FOLDER="$REPO_NAME_ALPHANUMERIC/$PULL_REQUEST_NAME" # Deploy safe-team project - aws s3 sync build_webpack s3://${REVIEW_BUCKET_NAME}/${REVIEW_FEATURE_FOLDER}/app --delete + aws s3 sync build s3://${REVIEW_BUCKET_NAME}/${REVIEW_FEATURE_FOLDER}/app --delete } function publish_pull_request_urls_in_github { diff --git a/config/travis/deploy_release.sh b/config/travis/deploy_release.sh index 1299e76c..b7d1d5d3 100755 --- a/config/travis/deploy_release.sh +++ b/config/travis/deploy_release.sh @@ -18,7 +18,7 @@ then REVIEW_RELEASE_FOLDER="$REPO_NAME_ALPHANUMERIC/$TRAVIS_TAG_ALPHANUMERIC" # Deploy safe-team release project - aws s3 sync build_webpack s3://${REVIEW_BUCKET_NAME}/${REVIEW_RELEASE_FOLDER}/app --delete --exclude "*.html" --exclude "/page-data" --cache-control max-age=31536000,public + aws s3 sync build s3://${REVIEW_BUCKET_NAME}/${REVIEW_RELEASE_FOLDER}/app --delete --exclude "*.html" --exclude "/page-data" --cache-control max-age=31536000,public - aws s3 sync build_webpack s3://${REVIEW_BUCKET_NAME}/${REVIEW_RELEASE_FOLDER}/app --delete --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html + aws s3 sync build s3://${REVIEW_BUCKET_NAME}/${REVIEW_RELEASE_FOLDER}/app --delete --exclude "*" --include "*.html" --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html fi diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js deleted file mode 100644 index 01d51764..00000000 --- a/config/webpack.config.dev.js +++ /dev/null @@ -1,159 +0,0 @@ -/*eslint-disable*/ -const autoprefixer = require('autoprefixer') -const cssmixins = require('postcss-mixins') -const cssvars = require('postcss-simple-vars') -const webpack = require('webpack') -const HtmlWebPackPlugin = require('html-webpack-plugin') - -const paths = require('./paths') -const getClientEnvironment = require('./env') - -const publicPath = '/' - -// `publicUrl` we will provide it to our app -// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript. -// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz. -var publicUrl = '' -// Get environment variables to inject into our app. -var env = getClientEnvironment(publicUrl) - -const cssvariables = require(paths.appSrc + '/theme/variables') - -const postcssPlugins = [ - autoprefixer({ - overrideBrowserslist: [ - '>1%', - 'last 4 versions', - 'Firefox ESR', - 'not ie < 9', // React doesn't support IE8 anyway - ], - }), - cssmixins, - cssvars({ - variables: function() { - return Object.assign({}, cssvariables) - }, - silent: false, - }), -] - -module.exports = { - devtool: 'eval-source-map', - mode: 'development', - entry: [ - 'babel-polyfill', - // Include an alternative client for WebpackDevServer. A client's job is to - // connect to WebpackDevServer by a socket and get notified about changes. - // When you save a file, the client will either apply hot updates (in case - // of CSS changes), or refresh the page (in case of JS changes). When you - // make a syntax error, this client will display a syntax error overlay. - // Note: instead of the default WebpackDevServer client, we use a custom one - // to bring better experience for Create React App users. You can replace - // the line below with these two lines if you prefer the stock client: - // require.resolve('webpack-dev-server/client') + '?/', - // require.resolve('webpack/hot/dev-server'), - require.resolve('react-dev-utils/webpackHotDevClient'), - // We ship a few polyfills by default: - require.resolve('./polyfills'), - // Finally, this is your app's code: - paths.appIndexJs, - // We include the app code last so that if there is a runtime error during - // initialization, it doesn't blow up the WebpackDevServer client, and - // changing JS code would still trigger a refresh. - ], - resolve: { - modules: [paths.appSrc, 'node_modules', paths.appContracts], - // 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/facebookincubator/create-react-app/issues/290 - extensions: ['.js', '.json', '.jsx'], - alias: { - '~': paths.appSrc, - '#': paths.appContracts, - }, - }, - output: { - // Next line is not used in dev but WebpackDevServer crashes without it: - path: paths.appBuild, - // Add /* filename */ comments to generated require()s in the output. - pathinfo: true, - // This does not produce a real file. It's just the virtual path that is - // served by WebpackDevServer in development. This is the JS bundle - // containing code from all our entry points, and the Webpack runtime. - filename: 'static/js/bundle.js', - // This is the URL that app is served from. We use "/" in development. - publicPath: publicPath, - }, - module: { - rules: [ - { - test: /\.(js|jsx)$/, - exclude: /node_modules/, - use: { - loader: 'babel-loader', - }, - }, - { - test: /\.(scss|css)$/, - use: [ - 'style-loader', - { - loader: 'css-loader', - options: { - importLoaders: 1, - modules: { - localIdentName: '[name]__[local]___[hash:base64:5]', - }, - }, - }, - { - loader: 'postcss-loader', - options: { - sourceMap: true, - plugins: postcssPlugins, - }, - }, - ], - }, - { test: /\.(woff|woff2)$/, loader: 'url-loader?limit=100000' }, - { - test: /\.html$/, - use: [ - { - loader: 'html-loader', - options: { minimize: false }, - }, - ], - }, - { - test: /\.(jpe?g|png|svg)$/i, - exclude: /node_modules/, - use: [ - { - loader: 'file-loader', - options: { - esModule: false, - name: 'img/[hash].[ext]', - esModule: false - }, - }, - ], - }, - ], - }, - plugins: [ - new HtmlWebPackPlugin({ - template: paths.appHtml, - }), - new webpack.DefinePlugin(env), - new webpack.HotModuleReplacementPlugin(), - ], - // Some libraries import Node modules but don't use them in the browser. - // Tell Webpack to provide empty mocks for them so importing them works. - node: { - fs: 'empty', - net: 'empty', - tls: 'empty', - }, -} diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js deleted file mode 100644 index cae3bcff..00000000 --- a/config/webpack.config.prod.js +++ /dev/null @@ -1,236 +0,0 @@ -/*eslint-disable*/ -const BundleAnalyzerPlugin = require("webpack-bundle-analyzer") - .BundleAnalyzerPlugin -const autoprefixer = require("autoprefixer") -const cssmixins = require("postcss-mixins") -const cssvars = require("postcss-simple-vars") -const webpack = require("webpack") - -const TerserPlugin = require("terser-webpack-plugin") -const HtmlWebpackPlugin = require("html-webpack-plugin") -const ExtractTextPlugin = require("extract-text-webpack-plugin") -const ManifestPlugin = require("webpack-manifest-plugin") -const MiniCssExtractPlugin = require("mini-css-extract-plugin") -const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin") - -const url = require("url") -const paths = require("./paths") -const getClientEnvironment = require("./env") - -const cssvariables = require(`${paths.appSrc}/theme/variables`) - -const postcssPlugins = [ - autoprefixer({ - overrideBrowserslist: [ - ">1%", - "last 4 versions", - "Firefox ESR", - "not ie < 9" // React doesn't support IE8 anyway - ] - }), - cssmixins, - cssvars({ - variables() { - return Object.assign({}, cssvariables) - }, - silent: true - }) -] - -function ensureSlash(path, needsSlash) { - const hasSlash = path.endsWith("/") - if (hasSlash && !needsSlash) { - return path.substr(path, path.length - 1) - } else if (!hasSlash && needsSlash) { - return `${path}/` - } - return path -} - -// We use "homepage" field to infer "public path" at which the app is served. -// Webpack needs to know it to put the right