Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimizer - allow out-of-band plugins #6177

Merged
merged 4 commits into from
Feb 12, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/cli/cluster/cluster_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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');
Expand All @@ -86,7 +92,7 @@ module.exports = class ClusterManager {
'src/ui',
'src/utils',
'config',
'installedPlugins'
...extraPaths
], {
cwd: fromRoot('.'),
ignored: /[\\\/](\..*|node_modules|bower_components|public|__tests__)[\\\/]/
Expand Down
16 changes: 12 additions & 4 deletions src/optimize/BaseOptimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this added function called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alias: transform(pkg.dependencies, function (aliases, version, name) {
if (name.endsWith('-loader')) {
aliases[name.replace(/-loader$/, '')] = require.resolve(name);
}
}, {})
}
};
}

Expand Down