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

Resave and Timestamps #24

Merged
merged 1 commit into from
Dec 28, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions bin/config-yargs.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ module.exports = function(yargs) {
describe: "Watch the filesystem for changes",
group: BASIC_GROUP
},
"save": {
type: "boolean",
alias: "s",
describe: "Rebuilds on save regardless of changes in watch mode",
group: BASIC_GROUP
},
"watch-stdin": {
type: "boolean",
alias: "stdin",
Expand Down
22 changes: 11 additions & 11 deletions bin/convert-argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var path = require("path");
var fs = require("fs");
fs.existsSync = fs.existsSync || path.existsSync;
var interpret = require("interpret");
var WebpackOptionsDefaulter = require("../node_modules/webpack/lib/WebpackOptionsDefaulter");
var WebpackOptionsDefaulter = require("webpack/lib/WebpackOptionsDefaulter");

module.exports = function(yargs, argv, convertOptions) {

Expand Down Expand Up @@ -317,7 +317,7 @@ module.exports = function(yargs, argv, convertOptions) {
defineObject = {};
}, function() {
ensureArray(options, "plugins");
var DefinePlugin = require("../node_modules/webpack/lib/DefinePlugin");
var DefinePlugin = require("webpack/lib/DefinePlugin");
options.plugins.push(new DefinePlugin(defineObject));
});

Expand Down Expand Up @@ -387,13 +387,13 @@ module.exports = function(yargs, argv, convertOptions) {

ifBooleanArg("hot", function() {
ensureArray(options, "plugins");
var HotModuleReplacementPlugin = require("../node_modules/webpack/lib/HotModuleReplacementPlugin");
var HotModuleReplacementPlugin = require("webpack/lib/HotModuleReplacementPlugin");
options.plugins.push(new HotModuleReplacementPlugin());
});

ifBooleanArg("debug", function() {
ensureArray(options, "plugins");
var LoaderOptionsPlugin = require("../node_modules/webpack/lib/LoaderOptionsPlugin");
var LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin");
options.plugins.push(new LoaderOptionsPlugin({
debug: true
}));
Expand Down Expand Up @@ -427,24 +427,24 @@ module.exports = function(yargs, argv, convertOptions) {

ifArg("optimize-max-chunks", function(value) {
ensureArray(options, "plugins");
var LimitChunkCountPlugin = require("../node_modules/webpack/lib/optimize/LimitChunkCountPlugin");
var LimitChunkCountPlugin = require("webpack/lib/optimize/LimitChunkCountPlugin");
options.plugins.push(new LimitChunkCountPlugin({
maxChunks: parseInt(value, 10)
}));
});

ifArg("optimize-min-chunk-size", function(value) {
ensureArray(options, "plugins");
var MinChunkSizePlugin = require("../node_modules/webpack/lib/optimize/MinChunkSizePlugin");
var MinChunkSizePlugin = require("webpack/lib/optimize/MinChunkSizePlugin");
options.plugins.push(new MinChunkSizePlugin({
minChunkSize: parseInt(value, 10)
}));
});

ifBooleanArg("optimize-minimize", function() {
ensureArray(options, "plugins");
var UglifyJsPlugin = require("../node_modules/webpack/lib/optimize/UglifyJsPlugin");
var LoaderOptionsPlugin = require("../node_modules/webpack/lib/LoaderOptionsPlugin");
var UglifyJsPlugin = require("webpack/lib/optimize/UglifyJsPlugin");
var LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin");
options.plugins.push(new UglifyJsPlugin({
sourceMap: options.devtool && (options.devtool.indexOf("sourcemap") >= 0 || options.devtool.indexOf("source-map") >= 0)
}));
Expand All @@ -455,7 +455,7 @@ module.exports = function(yargs, argv, convertOptions) {

ifArg("prefetch", function(request) {
ensureArray(options, "plugins");
var PrefetchPlugin = require("../node_modules/webpack/PrefetchPlugin");
var PrefetchPlugin = require("webpack/PrefetchPlugin");
options.plugins.push(new PrefetchPlugin(request));
});

Expand All @@ -469,13 +469,13 @@ module.exports = function(yargs, argv, convertOptions) {
} else {
name = value;
}
var ProvidePlugin = require("../node_modules/webpack/ProvidePlugin");
var ProvidePlugin = require("webpack/ProvidePlugin");
options.plugins.push(new ProvidePlugin(name, value));
});

ifBooleanArg("labeled-modules", function() {
ensureArray(options, "plugins");
var LabeledModulesPlugin = require("../node_modules/webpack/lib/dependencies/LabeledModulesPlugin");
var LabeledModulesPlugin = require("webpack/lib/dependencies/LabeledModulesPlugin");
options.plugins.push(new LabeledModulesPlugin());
});

Expand Down
10 changes: 6 additions & 4 deletions bin/process-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function processOptions(yargs, argv) {
var firstOptions = Array.isArray(options) ? (options[0] || {}) : options;

if(typeof options.stats === "boolean" || typeof options.stats === "string") {
var statsPresetToOptions = require("../lib/Stats.js").presetToOptions;
var statsPresetToOptions = require("webpack/lib/Stats.js").presetToOptions;
options.stats = statsPresetToOptions(options.stats);
}

Expand Down Expand Up @@ -125,15 +125,15 @@ module.exports = function processOptions(yargs, argv) {
}
});

var webpack = require("../lib/webpack.js");
var webpack = require("webpack/lib/webpack.js");

Error.stackTraceLimit = 30;
var lastHash = null;
var compiler;
try {
compiler = webpack(options);
} catch(e) {
var WebpackOptionsValidationError = require("../lib/WebpackOptionsValidationError");
var WebpackOptionsValidationError = require("webpack/lib/WebpackOptionsValidationError");
if(e instanceof WebpackOptionsValidationError) {
if(argv.color)
console.error("\u001b[1m\u001b[31m" + e.message + "\u001b[39m\u001b[22m");
Expand All @@ -145,7 +145,7 @@ module.exports = function processOptions(yargs, argv) {
}

if(argv.progress) {
var ProgressPlugin = require("../lib/ProgressPlugin");
var ProgressPlugin = require("webpack/lib/ProgressPlugin");
compiler.apply(new ProgressPlugin({
profile: argv.profile
}));
Expand All @@ -167,7 +167,9 @@ module.exports = function processOptions(yargs, argv) {
process.stdout.write(JSON.stringify(stats.toJson(outputOptions), null, 2) + "\n");
} else if(stats.hash !== lastHash) {
lastHash = stats.hash;
process.stdout.write( "\n" + new Date() + "\n" + "\n");
process.stdout.write(stats.toString(outputOptions) + "\n");
if(argv.s) lastHash = null;
Copy link

Choose a reason for hiding this comment

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

Im not sure what is happening here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Reset the hash, so webpack rebuilds.

}
if(!options.watch && stats.hasErrors()) {
process.on("exit", function() {
Expand Down
File renamed without changes.