Merge pull request #6177 from spalger/implement/supportPluginsAnywhere

optimizer - allow out-of-band plugins
This commit is contained in:
Spencer 2016-02-12 10:21:44 -07:00
commit 8023a36d88
3 changed files with 23 additions and 7 deletions

View file

@ -63,7 +63,13 @@ module.exports = class ClusterManager {
bindAll(this, 'onWatcherAdd', 'onWatcherError', 'onWatcherChange');
if (opts.watch) this.setupWatching();
if (opts.watch) {
this.setupWatching([
...settings.plugins.paths,
...settings.plugins.scanDirs
]);
}
else this.startCluster();
}
@ -75,7 +81,7 @@ module.exports = class ClusterManager {
}
}
setupWatching() {
setupWatching(extraPaths) {
const chokidar = require('chokidar');
const utils = require('requirefrom')('src/utils');
const fromRoot = utils('fromRoot');
@ -86,7 +92,7 @@ module.exports = class ClusterManager {
'src/ui',
'src/utils',
'config',
'installedPlugins'
...extraPaths
], {
cwd: fromRoot('.'),
ignored: /[\\\/](\..*|node_modules|bower_components|public|__tests__)[\\\/]/

View file

@ -4,14 +4,14 @@ import DirectoryNameAsMain from 'webpack-directory-name-as-main';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import CommonsChunkPlugin from 'webpack/lib/optimize/CommonsChunkPlugin';
let utils = require('requirefrom')('src/utils');
let fromRoot = utils('fromRoot');
import fromRoot from '../utils/fromRoot';
import babelOptions from './babelOptions';
import { inherits } from 'util';
import { defaults } from 'lodash';
import { defaults, transform } from 'lodash';
import { resolve } from 'path';
import { writeFile } from 'fs';
let babelExclude = [/[\/\\](webpackShims|node_modules|bower_components)[\/\\]/];
import pkg from '../../package.json';
class BaseOptimizer {
constructor(opts) {
@ -133,12 +133,20 @@ class BaseOptimizer {
resolve: {
extensions: ['.js', '.json', '.jsx', '.less', ''],
postfixes: [''],
modulesDirectories: ['webpackShims', 'node_modules'],
modulesDirectories: ['webpackShims', 'node_modules', fromRoot('webpackShims'), fromRoot('node_modules')],
loaderPostfixes: ['-loader', ''],
root: fromRoot('.'),
alias: this.env.aliases,
unsafeCache: this.unsafeCache,
},
resolveLoader: {
alias: transform(pkg.dependencies, function (aliases, version, name) {
if (name.endsWith('-loader')) {
aliases[name.replace(/-loader$/, '')] = require.resolve(name);
}
}, {})
}
};
}

View file

@ -12,3 +12,5 @@ exports.webpack = {
};
exports.node = cloneDeep(exports.webpack);
exports.node.optional = ['asyncToGenerator'];
exports.node.blacklist = ['regenerator'];