mirror of
https://github.com/status-im/sourcecred.git
synced 2025-01-11 13:14:28 +00:00
upgrade to webpack 4
Now that babel is upgraded, upgrading webpack was pretty straightforward. - We take advantage of the new `mode` config option, and no longer need to manually set up Uglify plugin - Uglifyjs is back, I checked the prod build output: it's very ugly - I updated the RemoveBuildDirectoryPlugin per instructions, and verified it still works. - I verified that of `yarn backend`, `yarn build`, and `yarn start` all still work as expected.
This commit is contained in:
parent
f77ff3ecd0
commit
a0b754bb43
@ -6,19 +6,10 @@ const path = require("path");
|
|||||||
// Note: the following type-import just resolves to `any`.
|
// Note: the following type-import just resolves to `any`.
|
||||||
/*:: import type {Compiler} from "webpack"; */
|
/*:: import type {Compiler} from "webpack"; */
|
||||||
|
|
||||||
module.exports = class RemoveBuildDirectoryPlugin {
|
const pluginName = "RemoveBuildDirectoryPlugin";
|
||||||
|
class RemoveBuildDirectoryPlugin {
|
||||||
apply(compiler /*: Compiler */) {
|
apply(compiler /*: Compiler */) {
|
||||||
if (compiler.hooks) {
|
compiler.hooks.run.tap(pluginName, () => {
|
||||||
console.warn(
|
|
||||||
"" +
|
|
||||||
"You appear to be running Webpack >= 4. " +
|
|
||||||
"The RemoveBuildDirectoryPlugin should be forward-compatible, " +
|
|
||||||
"but you should update it to use the new APIs. See " +
|
|
||||||
"<https://github.com/webpack/webpack/releases/tag/v4.0.0-beta.0> " +
|
|
||||||
"for details."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
compiler.plugin("compile", () => {
|
|
||||||
const outputPath = compiler.options.output.path;
|
const outputPath = compiler.options.output.path;
|
||||||
// If a build config has no `output.path` property, and no
|
// If a build config has no `output.path` property, and no
|
||||||
// `--output-path` is passed on the command line, then Webpack
|
// `--output-path` is passed on the command line, then Webpack
|
||||||
@ -35,4 +26,6 @@ module.exports = class RemoveBuildDirectoryPlugin {
|
|||||||
fs.emptyDirSync(outputPath);
|
fs.emptyDirSync(outputPath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
module.exports = RemoveBuildDirectoryPlugin;
|
||||||
|
@ -73,4 +73,5 @@ module.exports = {
|
|||||||
new RemoveBuildDirectoryPlugin(),
|
new RemoveBuildDirectoryPlugin(),
|
||||||
new webpack.DefinePlugin(env.individuallyStringified),
|
new webpack.DefinePlugin(env.individuallyStringified),
|
||||||
],
|
],
|
||||||
|
mode: process.env.NODE_ENV,
|
||||||
};
|
};
|
||||||
|
@ -118,6 +118,7 @@ function makeConfig(mode /*: "production" | "development" */) /*: mixed */ {
|
|||||||
.replace(/\\/g, "/"),
|
.replace(/\\/g, "/"),
|
||||||
// We need to use a UMD module to build the static site.
|
// We need to use a UMD module to build the static site.
|
||||||
libraryTarget: "umd",
|
libraryTarget: "umd",
|
||||||
|
globalObject: "this",
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
// This allows you to set a fallback for where Webpack should look for modules.
|
// This allows you to set a fallback for where Webpack should look for modules.
|
||||||
@ -220,6 +221,7 @@ function makeConfig(mode /*: "production" | "development" */) /*: mixed */ {
|
|||||||
tls: "empty",
|
tls: "empty",
|
||||||
child_process: "empty",
|
child_process: "empty",
|
||||||
},
|
},
|
||||||
|
mode,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
package.json
22
package.json
@ -41,8 +41,8 @@
|
|||||||
"babel-eslint": "^10.0.2",
|
"babel-eslint": "^10.0.2",
|
||||||
"babel-jest": "^24.8.0",
|
"babel-jest": "^24.8.0",
|
||||||
"babel-loader": "^8.0.6",
|
"babel-loader": "^8.0.6",
|
||||||
"copy-webpack-plugin": "^4.5.2",
|
"copy-webpack-plugin": "^5.0.3",
|
||||||
"css-loader": "0.28.7",
|
"css-loader": "^3.0.0",
|
||||||
"dotenv": "8.0.0",
|
"dotenv": "8.0.0",
|
||||||
"dotenv-expand": "5.1.0",
|
"dotenv-expand": "5.1.0",
|
||||||
"enzyme": "^3.3.0",
|
"enzyme": "^3.3.0",
|
||||||
@ -53,7 +53,7 @@
|
|||||||
"eslint-plugin-import": "2.18.0",
|
"eslint-plugin-import": "2.18.0",
|
||||||
"eslint-plugin-jsx-a11y": "6.2.3",
|
"eslint-plugin-jsx-a11y": "6.2.3",
|
||||||
"eslint-plugin-react": "7.14.2",
|
"eslint-plugin-react": "7.14.2",
|
||||||
"file-loader": "1.1.5",
|
"file-loader": "^4.0.0",
|
||||||
"flow-bin": "^0.100.0",
|
"flow-bin": "^0.100.0",
|
||||||
"jest": "^24.8.0",
|
"jest": "^24.8.0",
|
||||||
"jest-fetch-mock": "^2.1.2",
|
"jest-fetch-mock": "^2.1.2",
|
||||||
@ -61,24 +61,18 @@
|
|||||||
"raf": "3.4.1",
|
"raf": "3.4.1",
|
||||||
"react-dev-utils": "^5.0.0",
|
"react-dev-utils": "^5.0.0",
|
||||||
"static-site-generator-webpack-plugin": "^3.4.1",
|
"static-site-generator-webpack-plugin": "^3.4.1",
|
||||||
"url-loader": "0.6.2",
|
"url-loader": "^2.0.1",
|
||||||
"webpack": "^3.8.1",
|
"webpack": "^4.35.3",
|
||||||
"webpack-dev-server": "2.9.4",
|
"webpack-cli": "^3.3.5",
|
||||||
"webpack-manifest-plugin": "1.3.2",
|
"webpack-dev-server": "^3.7.2",
|
||||||
|
"webpack-manifest-plugin": "^2.0.4",
|
||||||
"webpack-node-externals": "^1.7.2"
|
"webpack-node-externals": "^1.7.2"
|
||||||
},
|
},
|
||||||
"greenkeeper": {
|
"greenkeeper": {
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"copy-webpack-plugin",
|
|
||||||
"css-loader",
|
|
||||||
"file-loader",
|
|
||||||
"history",
|
"history",
|
||||||
"react-dev-utils",
|
"react-dev-utils",
|
||||||
"react-router",
|
"react-router",
|
||||||
"url-loader",
|
|
||||||
"webpack",
|
|
||||||
"webpack-dev-server",
|
|
||||||
"webpack-manifest-plugin",
|
|
||||||
"whatwg-fetch"
|
"whatwg-fetch"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user