npm and error messages

This commit is contained in:
2018-10-27 03:51:47 -05:00
parent 692ab70565
commit 025a403027
29601 changed files with 2759363 additions and 14 deletions

View File

@@ -0,0 +1,21 @@
class BuildCallbackPlugin {
/**
* Create a new plugin instance.
*
* @param {Function} callback
*/
constructor(callback) {
this.callback = callback;
}
/**
* Apply the plugin.
*
* @param {Object} compiler
*/
apply(compiler) {
compiler.plugin('done', this.callback);
}
}
module.exports = BuildCallbackPlugin;

View File

@@ -0,0 +1,31 @@
let Purifier = require('purifycss-webpack');
let glob = require('glob');
class CssPurifierPlugin {
/**
* Build up the plugin.
*/
static build() {
let bladeFiles = glob.sync(
Mix.paths.root('resources/views/**/*.blade.php')
);
let vueFiles = glob.sync(
Mix.paths.root('resources/assets/js/**/*.vue')
);
let paths = bladeFiles.concat(vueFiles);
if (Config.purifyCss.paths) {
paths = paths.concat(Config.purifyCss.paths);
}
return new Purifier(
Object.assign({}, Config.purifyCss, {
paths,
minimize: Mix.inProduction()
})
);
}
}
module.exports = CssPurifierPlugin;

View File

@@ -0,0 +1,80 @@
class CustomTasksPlugin {
/**
* Apply the plugin.
*
* @param {Object} compiler
*/
apply(compiler) {
compiler.plugin('done', stats => {
Mix.tasks.forEach(task => this.runTask(task, stats));
if (Mix.components.get('version')) {
this.applyVersioning();
}
if (Mix.inProduction()) {
this.minifyAssets();
}
if (Mix.isWatching()) {
Mix.tasks.forEach(task => task.watch(Mix.isPolling()));
}
Mix.manifest.refresh();
});
}
/**
* Execute the task.
*
* @param {Task} task
*/
runTask(task, stats) {
task.run();
task.assets.forEach(asset => {
Mix.manifest.add(asset.pathFromPublic());
// Update the Webpack assets list for better terminal output.
stats.compilation.assets[asset.pathFromPublic()] = {
size: () => asset.size(),
emitted: true
};
});
}
/**
* Minify the given asset file.
*/
minifyAssets() {
let tasks = Mix.tasks.filter(task => {
return task.constructor.name !== 'VersionFilesTask' && task.constructor.name !== 'CopyFilesTask';
});
tasks.forEach(task => {
task.assets.forEach(asset => {
try {
asset.minify();
} catch (e) {
console.log(
`Whoops! We had trouble minifying "${asset.relativePath()}". ` +
`Perhaps you need to use mix.babel() instead?`
);
throw e;
}
});
});
}
/**
* Version all files that are present in the manifest.
*/
applyVersioning() {
let manifest = Object.keys(Mix.manifest.get());
manifest.forEach(file => Mix.manifest.hash(file));
}
}
module.exports = CustomTasksPlugin;

View File

@@ -0,0 +1,27 @@
let StandaloneSass = require('../StandaloneSass');
class FastSassPlugin {
/**
* Create a new plugin instance.
*
* @param {Array} files
*/
constructor(files = []) {
this.files = files;
}
/**
* Apply the plugin.
*/
apply() {
this.files.forEach(sass => {
new StandaloneSass(
sass.src,
sass.output.forceFromPublic(),
sass.pluginOptions
).run();
});
}
}
module.exports = FastSassPlugin;

View File

@@ -0,0 +1,19 @@
class ManifestPlugin {
/**
* Apply the plugin.
*
* @param {Object} compiler
*/
apply(compiler) {
compiler.plugin('emit', (curCompiler, callback) => {
let stats = curCompiler.getStats().toJson();
// Handle the creation of the mix-manifest.json file.
Mix.manifest.transform(stats).refresh();
callback();
});
}
}
module.exports = ManifestPlugin;

View File

@@ -0,0 +1,59 @@
let webpack = require('webpack');
let dotenv = require('dotenv');
let expand = require('dotenv-expand');
/**
* Create a new plugin instance.
*
* @param {string} envPath
*/
function MixDefinitionsPlugin(envPath) {
expand(
dotenv.config({
path: envPath || Mix.paths.root('.env')
})
);
}
/**
* Build up the necessary definitions and add them to the DefinePlugin.
*
* @param {Object|null} merge
*/
MixDefinitionsPlugin.build = function(merge = {}) {
return new webpack.DefinePlugin(
new MixDefinitionsPlugin().getDefinitions(merge)
);
};
/**
* Build all MIX_ definitions for Webpack's DefinePlugin.
*
* @param {object} merge
*/
MixDefinitionsPlugin.prototype.getDefinitions = function(merge) {
let regex = /^MIX_/i;
// Filter out env vars that don't begin with MIX_.
let env = Object.keys(process.env)
.filter(key => regex.test(key))
.reduce((value, key) => {
value[key] = process.env[key];
return value;
}, {});
let values = Object.assign(env, merge);
return {
'process.env': Object.keys(values)
// Stringify all values so they can be fed into Webpack's DefinePlugin.
.reduce((value, key) => {
value[key] = JSON.stringify(values[key]);
return value;
}, {})
};
};
module.exports = MixDefinitionsPlugin;

View File

@@ -0,0 +1,29 @@
class MockEntryPlugin {
/**
* Handle the deletion of the temporary mix.js
* output file that was generated by webpack.
*
* This file is created when the user hasn't
* requested any JavaScript compilation, but
* webpack still requires an entry.
*
* @param {Object} compiler
*/
apply(compiler) {
compiler.plugin('done', stats => {
let temporaryOutputFile = stats
.toJson()
.assets.find(asset => asset.name === 'mix.js');
if (temporaryOutputFile) {
delete stats.compilation.assets[temporaryOutputFile.name];
File.find(
path.resolve(Config.publicPath, temporaryOutputFile.name)
).delete();
}
});
}
}
module.exports = MockEntryPlugin;