Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120688486
WebpackCLIPlugin.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jul 6, 08:01
Size
2 KB
Mime Type
text/x-c++
Expires
Tue, Jul 8, 08:01 (2 d)
Engine
blob
Format
Raw Data
Handle
27216872
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
WebpackCLIPlugin.js
View Options
const { packageExists } = require('../utils/package-exists');
const webpack = packageExists('webpack') ? require('webpack') : undefined;
const logger = require('../utils/logger');
const PluginName = 'webpack-cli';
class WebpackCLIPlugin {
constructor(options) {
this.options = options;
}
async apply(compiler) {
const compilers = compiler.compilers || [compiler];
for (const compiler of compilers) {
if (this.options.progress) {
const { ProgressPlugin } = compiler.webpack || webpack;
let progressPluginExists;
if (compiler.options.plugins) {
progressPluginExists = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof ProgressPlugin));
}
if (!progressPluginExists) {
if (typeof this.options.progress === 'string' && this.options.progress !== 'profile') {
logger.error(
`'${this.options.progress}' is an invalid value for the --progress option. Only 'profile' is allowed.`,
);
process.exit(2);
}
const isProfile = this.options.progress === 'profile';
new ProgressPlugin({ profile: isProfile }).apply(compiler);
}
}
}
const compilationName = (compilation) => (compilation.name ? ` ${compilation.name}` : '');
compiler.hooks.watchRun.tap(PluginName, (compilation) => {
const { bail, watch } = compilation.options;
if (bail && watch) {
logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.');
}
logger.success(`Compilation${compilationName(compilation)} starting...`);
});
compiler.hooks.done.tap(PluginName, (compilation) => {
logger.success(`Compilation${compilationName(compilation)} finished`);
process.nextTick(() => {
if (compiler.watchMode) {
logger.success('watching files for updates...');
}
});
});
}
}
module.exports = WebpackCLIPlugin;
Event Timeline
Log In to Comment