diff --git a/apps/etherscan/.babelrc b/apps/etherscan/.babelrc index b1fc975456..9123728aa1 100644 --- a/apps/etherscan/.babelrc +++ b/apps/etherscan/.babelrc @@ -1,13 +1,9 @@ { - "presets": [ - [ - "@nrwl/react/babel", { - "runtime": "automatic" - - } - ] - ], - "plugins": [ - + "presets": ["@babel/preset-env", ["@babel/preset-react", + {"runtime": "automatic"} + ]], + "plugins": ["@babel/plugin-proposal-class-properties", "@babel/plugin-transform-runtime", "@babel/plugin-proposal-nullish-coalescing-operator"], + "ignore": [ + "**/node_modules/**" ] } diff --git a/apps/etherscan/webpack.config.js b/apps/etherscan/webpack.config.js index 68ea64e4a1..45c7c5dd14 100644 --- a/apps/etherscan/webpack.config.js +++ b/apps/etherscan/webpack.config.js @@ -1,28 +1,82 @@ -const nxWebpack = require('@nrwl/react/plugins/webpack') - -module.exports = config => { - const nxWebpackConfig = nxWebpack(config) - const webpackConfig = { - ...nxWebpackConfig, - resolve : { - ...nxWebpackConfig.resolve, - fallback: { - ...nxWebpackConfig.resolve.fallback, - "http": require.resolve("stream-http"), - "https": require.resolve("https-browserify"), - "stream": require.resolve("stream-browserify"), - "zlib": require.resolve("browserify-zlib"), - }, - } +const { composePlugins, withNx } = require('@nrwl/webpack') +const webpack = require('webpack') +const TerserPlugin = require("terser-webpack-plugin") +const CssMinimizerPlugin = require("css-minimizer-webpack-plugin") + +// Nx plugins for webpack. +module.exports = composePlugins(withNx(), (config) => { + // Update the webpack config as needed here. + // e.g. `config.plugins.push(new MyPlugin())` + + // add fallback for node modules + config.resolve.fallback = { + ...config.resolve.fallback, + "crypto": require.resolve("crypto-browserify"), + "stream": require.resolve("stream-browserify"), + "path": require.resolve("path-browserify"), + "http": require.resolve("stream-http"), + "https": require.resolve("https-browserify"), + "constants": require.resolve("constants-browserify"), + "os": false, //require.resolve("os-browserify/browser"), + "timers": false, // require.resolve("timers-browserify"), + "zlib": require.resolve("browserify-zlib"), + "fs": false, + "module": false, + "tls": false, + "net": false, + "readline": false, + "child_process": false, + "buffer": require.resolve("buffer/"), + "vm": require.resolve('vm-browserify'), } + - if (process.env.NODE_ENV === 'production') { - return { - ...webpackConfig, - mode: 'production', - devtool: 'source-map', - } - } else { - return webpackConfig + // add externals + config.externals = { + ...config.externals, + solc: 'solc', } -} + + // add public path + config.output.publicPath = '/' + + + + // add copy & provide plugin + config.plugins.push( + new webpack.ProvidePlugin({ + Buffer: ['buffer', 'Buffer'], + url: ['url', 'URL'], + process: 'process/browser', + }) + ) + + // souce-map loader + config.module.rules.push({ + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre" + }) + + config.ignoreWarnings = [/Failed to parse source map/] // ignore source-map-loader warnings + + + // set minimizer + config.optimization.minimizer = [ + new TerserPlugin({ + parallel: true, + terserOptions: { + ecma: 2015, + compress: false, + mangle: false, + format: { + comments: false, + }, + }, + extractComments: false, + }), + new CssMinimizerPlugin(), + ]; + + return config; +}); diff --git a/apps/remix-ide-e2e/src/local-plugin/project.json b/apps/remix-ide-e2e/src/local-plugin/project.json index e0e8d88be4..e6c034643c 100644 --- a/apps/remix-ide-e2e/src/local-plugin/project.json +++ b/apps/remix-ide-e2e/src/local-plugin/project.json @@ -25,7 +25,7 @@ "apps/remix-ide-e2e/src/local-plugin/src/styles.css" ], "scripts": [], - "webpackConfig": "@nrwl/react/plugins/webpack" + "webpackConfig": "apps/remix-ide-e2e/src/local-plugin/webpack.config.js" }, "configurations": { "development": { diff --git a/apps/remix-ide-e2e/src/local-plugin/webpack.config.js b/apps/remix-ide-e2e/src/local-plugin/webpack.config.js new file mode 100644 index 0000000000..45c7c5dd14 --- /dev/null +++ b/apps/remix-ide-e2e/src/local-plugin/webpack.config.js @@ -0,0 +1,82 @@ +const { composePlugins, withNx } = require('@nrwl/webpack') +const webpack = require('webpack') +const TerserPlugin = require("terser-webpack-plugin") +const CssMinimizerPlugin = require("css-minimizer-webpack-plugin") + +// Nx plugins for webpack. +module.exports = composePlugins(withNx(), (config) => { + // Update the webpack config as needed here. + // e.g. `config.plugins.push(new MyPlugin())` + + // add fallback for node modules + config.resolve.fallback = { + ...config.resolve.fallback, + "crypto": require.resolve("crypto-browserify"), + "stream": require.resolve("stream-browserify"), + "path": require.resolve("path-browserify"), + "http": require.resolve("stream-http"), + "https": require.resolve("https-browserify"), + "constants": require.resolve("constants-browserify"), + "os": false, //require.resolve("os-browserify/browser"), + "timers": false, // require.resolve("timers-browserify"), + "zlib": require.resolve("browserify-zlib"), + "fs": false, + "module": false, + "tls": false, + "net": false, + "readline": false, + "child_process": false, + "buffer": require.resolve("buffer/"), + "vm": require.resolve('vm-browserify'), + } + + + // add externals + config.externals = { + ...config.externals, + solc: 'solc', + } + + // add public path + config.output.publicPath = '/' + + + + // add copy & provide plugin + config.plugins.push( + new webpack.ProvidePlugin({ + Buffer: ['buffer', 'Buffer'], + url: ['url', 'URL'], + process: 'process/browser', + }) + ) + + // souce-map loader + config.module.rules.push({ + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre" + }) + + config.ignoreWarnings = [/Failed to parse source map/] // ignore source-map-loader warnings + + + // set minimizer + config.optimization.minimizer = [ + new TerserPlugin({ + parallel: true, + terserOptions: { + ecma: 2015, + compress: false, + mangle: false, + format: { + comments: false, + }, + }, + extractComments: false, + }), + new CssMinimizerPlugin(), + ]; + + return config; +}); diff --git a/apps/vyper/webpack.config.js b/apps/vyper/webpack.config.js index 5bb78141c3..fa6f5e3b06 100644 --- a/apps/vyper/webpack.config.js +++ b/apps/vyper/webpack.config.js @@ -1,31 +1,83 @@ -const nxWebpack = require('@nrwl/react/plugins/webpack') - -module.exports = config => { - const nxWebpackConfig = nxWebpack(config) - const webpackConfig = { - ...nxWebpackConfig, - resolve : { - ...nxWebpackConfig.resolve, - fallback: { - ...nxWebpackConfig.resolve.fallback, - "crypto": require.resolve("crypto-browserify"), - "stream": require.resolve("stream-browserify"), - "http" : require.resolve("stream-http"), - "https" : require.resolve("https-browserify"), - "path" : require.resolve("path-browserify"), - "module": false, - "fs" : false - }, - } +const { composePlugins, withNx } = require('@nrwl/webpack') +const webpack = require('webpack') +const TerserPlugin = require("terser-webpack-plugin") +const CssMinimizerPlugin = require("css-minimizer-webpack-plugin") + + +// Nx plugins for webpack. +module.exports = composePlugins(withNx(), (config) => { + // Update the webpack config as needed here. + // e.g. `config.plugins.push(new MyPlugin())` + + // add fallback for node modules + config.resolve.fallback = { + ...config.resolve.fallback, + "crypto": require.resolve("crypto-browserify"), + "stream": require.resolve("stream-browserify"), + "path": require.resolve("path-browserify"), + "http": require.resolve("stream-http"), + "https": require.resolve("https-browserify"), + "constants": require.resolve("constants-browserify"), + "os": false, //require.resolve("os-browserify/browser"), + "timers": false, // require.resolve("timers-browserify"), + "zlib": require.resolve("browserify-zlib"), + "fs": false, + "module": false, + "tls": false, + "net": false, + "readline": false, + "child_process": false, + "buffer": require.resolve("buffer/"), + "vm": require.resolve('vm-browserify'), } + - if (process.env.NODE_ENV === 'production') { - return { - ...webpackConfig, - mode: 'production', - devtool: 'source-map', - } - } else { - return webpackConfig + // add externals + config.externals = { + ...config.externals, + solc: 'solc', } -} + + // add public path + config.output.publicPath = '/' + + + + // add copy & provide plugin + config.plugins.push( + new webpack.ProvidePlugin({ + Buffer: ['buffer', 'Buffer'], + url: ['url', 'URL'], + process: 'process/browser', + }) + ) + + // souce-map loader + config.module.rules.push({ + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre" + }) + + config.ignoreWarnings = [/Failed to parse source map/] // ignore source-map-loader warnings + + + // set minimizer + config.optimization.minimizer = [ + new TerserPlugin({ + parallel: true, + terserOptions: { + ecma: 2015, + compress: false, + mangle: false, + format: { + comments: false, + }, + }, + extractComments: false, + }), + new CssMinimizerPlugin(), + ]; + + return config; +});