mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-11-14 11:37:06 +08:00
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
|
const path = require("path");
|
||
|
const CircularDependencyPlugin = require("circular-dependency-plugin");
|
||
|
|
||
|
module.exports = {
|
||
|
mode: "development", // Change to 'production' for production
|
||
|
devtool: false, // no SourceMap
|
||
|
entry: "./src/js/index.js",
|
||
|
resolve: {
|
||
|
fallback: {
|
||
|
crypto: require.resolve("crypto-browserify"),
|
||
|
stream: require.resolve("stream-browserify"),
|
||
|
},
|
||
|
},
|
||
|
output: {
|
||
|
path: path.resolve(__dirname, "public/js/"),
|
||
|
filename: "monkeytype.js",
|
||
|
},
|
||
|
plugins: [
|
||
|
new CircularDependencyPlugin({
|
||
|
// exclude detection of files based on a RegExp
|
||
|
exclude: /node_modules/,
|
||
|
// include specific files based on a RegExp
|
||
|
include: /./,
|
||
|
// add errors to webpack instead of warnings
|
||
|
failOnError: false,
|
||
|
// allow import cycles that include an asyncronous import,
|
||
|
// e.g. via import(/* webpackMode: "weak" */ './file.js')
|
||
|
allowAsyncCycles: false,
|
||
|
// set the current working directory for displaying module paths
|
||
|
cwd: process.cwd(),
|
||
|
onStart() {
|
||
|
console.log("start detecting webpack modules cycles");
|
||
|
},
|
||
|
// `onDetected` is called for each module that is cyclical
|
||
|
onDetected({ module: _webpackModuleRecord, paths, compilation }) {
|
||
|
// `paths` will be an Array of the relative module paths that make up the cycle
|
||
|
// `module` will be the module record generated by webpack that caused the cycle
|
||
|
compilation.errors.push(new Error(paths.join(" -> ")));
|
||
|
},
|
||
|
// `onEnd` is called before the cycle detection ends
|
||
|
onEnd() {
|
||
|
console.log("end detecting webpack modules cycles");
|
||
|
},
|
||
|
}),
|
||
|
],
|
||
|
};
|