1 | const defaultsDeep = require("lodash/defaultsDeep");
|
2 | const fs = require("fs-extra");
|
3 | const os = require("os");
|
4 |
|
5 | module.exports = function (options) {
|
6 | const browserslist = [
|
7 | ">=0.25%",
|
8 | "not dead",
|
9 | "not op_mini all",
|
10 | "not Android 4.4.3-4.4.4",
|
11 | "not ios_saf < 10",
|
12 |
|
13 | "not Chrome < 50",
|
14 | "firefox ESR",
|
15 | ];
|
16 |
|
17 | const pkgFile = process.cwd() + "/package.json";
|
18 | let pkg = {};
|
19 | if (fs.existsSync(pkgFile)) {
|
20 | pkg = require(pkgFile);
|
21 | }
|
22 |
|
23 | if (!pkg.browserslist) {
|
24 | pkg.browserslist = browserslist;
|
25 |
|
26 | fs.writeFileSync(pkgFile, JSON.stringify(pkg, null, 2) + os.EOL);
|
27 | }
|
28 |
|
29 | const defaults = {
|
30 | cwd: process.cwd(),
|
31 | glob: ["**/*", "**/*.*", "**/.*"],
|
32 | clean: true,
|
33 | watch: false,
|
34 | ignore: null,
|
35 | filter: null,
|
36 | babel: {
|
37 | decoratorsBeforeExport: true,
|
38 | strictMode: true,
|
39 | modules: "commonjs",
|
40 | useFlow: true,
|
41 | loose: true,
|
42 | runtimeOptions: {},
|
43 | presets: [],
|
44 | plugins: [],
|
45 | },
|
46 | typescript: {},
|
47 | postcss: {},
|
48 | eslint: {},
|
49 | scss: {},
|
50 | less: {},
|
51 | cssModule: {
|
52 | test: /\.module.(less|scss|css)$/,
|
53 | esModule: true,
|
54 | },
|
55 | raw: {
|
56 | test: /\.svg$/,
|
57 | },
|
58 |
|
59 | transform: null,
|
60 | };
|
61 |
|
62 | return defaultsDeep({}, options, defaults);
|
63 | };
|