UNPKG

1.13 kBJavaScriptView Raw
1const defaultsDeep = require("lodash/defaultsDeep");
2const fs = require("fs-extra");
3const os = require("os");
4
5module.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 // "not ie <= 11",
13 "not Chrome < 50", // caniuse lastest is reporting chrome 29
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 };
52
53 return defaultsDeep({}, options, defaults);
54};