Skip to content

Commit 5e8700f

Browse files
committed
feat(defaults): add fixed defaults
1 parent a1f8890 commit 5e8700f

File tree

5 files changed

+10
-27
lines changed

5 files changed

+10
-27
lines changed

lib/WebpackOptionsDefaulter.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
*/
55
"use strict";
66

7+
const path = require("path");
8+
79
const OptionsDefaulter = require("./OptionsDefaulter");
810
const Template = require("./Template");
911

1012
class WebpackOptionsDefaulter extends OptionsDefaulter {
1113
constructor() {
1214
super();
15+
16+
this.set("entry", "./src");
17+
this.set("mode", "production");
18+
1319
this.set("devtool", "make", options => options.mode === "development" ? "eval" : false);
1420
this.set("cache", "make", options => options.mode === "development");
1521

@@ -57,6 +63,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
5763
return Object.assign({}, value);
5864
}
5965
});
66+
6067
this.set("output.filename", "[name].js");
6168
this.set("output.chunkFilename", "make", (options) => {
6269
const filename = options.output.filename;
@@ -81,7 +88,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
8188
return options.output.library || "";
8289
});
8390
this.set("output.libraryTarget", "var");
84-
this.set("output.path", process.cwd());
91+
this.set("output.path", path.join(process.cwd(), "dist"));
8592
this.set("output.pathinfo", "make", options => options.mode === "development");
8693
this.set("output.sourceMapFilename", "[file].map[query]");
8794
this.set("output.hotUpdateChunkFilename", "[id].[hash].hot-update.js");

schemas/WebpackOptions.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,8 +1685,5 @@
16851685
"type": "object"
16861686
}
16871687
},
1688-
"required": [
1689-
"entry"
1690-
],
16911688
"type": "object"
16921689
}

test/Compiler-caching.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe("Compiler (caching)", function() {
1515
options = new WebpackOptionsDefaulter().process(options);
1616
options.cache = true;
1717
options.entry = entry;
18+
options.optimization.minimize = false;
1819
options.context = path.join(__dirname, "fixtures");
1920
options.output.path = "/";
2021
options.output.filename = "bundle.js";

test/Errors.test.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,6 @@ describe("Errors", () => {
9797
done();
9898
});
9999
});
100-
it("should warn when not using mode", (done) => {
101-
getErrors({
102-
entry: "./entry-point",
103-
}, (errors, warnings) => {
104-
errors.length.should.be.eql(0);
105-
warnings.length.should.be.eql(1);
106-
let lines = warnings[0].split("\n");
107-
lines[0].should.match(/configuration/);
108-
lines[1].should.match(/mode/);
109-
lines[1].should.match(/development/);
110-
lines[1].should.match(/production/);
111-
done();
112-
});
113-
});
114100
it("should not warn if the NoEmitOnErrorsPlugin is used over the NoErrorsPlugin", (done) => {
115101
getErrors({
116102
mode: "production",

test/Validation.test.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ describe("Validation", () => {
1818
message: [
1919
" - configuration should be an object."
2020
]
21-
}, {
22-
name: "empty configuration",
23-
config: {},
24-
message: [
25-
" - configuration misses the property 'entry'.",
26-
" object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function",
27-
" -> The entry point(s) of the compilation."
28-
]
2921
}, {
3022
name: "empty entry string",
3123
config: {
@@ -185,7 +177,7 @@ describe("Validation", () => {
185177
},
186178
message: [
187179
" - configuration has an unknown property 'postcss'. These properties are valid:",
188-
" object { mode?, amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, " +
180+
" object { mode?, amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, externals?, " +
189181
"loader?, module?, name?, node?, output?, optimization?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, " +
190182
"recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }",
191183
" For typos: please correct them.",

0 commit comments

Comments
 (0)