swico 2.1.0-beta.1 → 2.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swico",
3
- "version": "2.1.0-beta.1",
3
+ "version": "2.1.0-beta.3",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -44,6 +44,7 @@
44
44
  "less-loader": "12.2.0",
45
45
  "ora": "5.4.1",
46
46
  "portfinder": "1.0.32",
47
+ "postcss": "8.5.3",
47
48
  "postcss-loader": "8.1.0",
48
49
  "postcss-preset-env": "9.3.0",
49
50
  "qs": "6.13.0",
@@ -60,8 +61,8 @@
60
61
  "webpack-merge": "6.0.1"
61
62
  },
62
63
  "devDependencies": {
63
- "@rspack/core": "1.3.5",
64
64
  "@eslint/js": "9.24.0",
65
+ "@rspack/core": "1.3.5",
65
66
  "@types/node": "22.13.10",
66
67
  "@types/react": "19.1.0",
67
68
  "@types/react-dom": "19.1.0",
@@ -37,20 +37,21 @@ function default_1() {
37
37
  tools_1.toast.info('Building...');
38
38
  const now = Date.now();
39
39
  compiler.run((err, stats) => {
40
- const duration = Date.now() - now;
41
40
  if (err) {
42
41
  tools_1.toast.error(err.stack || err.toString());
43
42
  return;
44
43
  }
45
- const info = stats.toJson();
46
44
  if (stats.hasErrors()) {
45
+ const info = stats.toJson();
47
46
  tools_1.toast.error(info.errors.map((item) => item.stack || item.message));
48
47
  return;
49
48
  }
50
49
  if (stats.hasWarnings()) {
50
+ const info = stats.toJson();
51
51
  tools_1.toast.warning(info.warnings.map((item) => item.stack || item.message));
52
52
  }
53
- tools_1.toast.success(`Build complete ${(info === null || info === void 0 ? void 0 : info.time) ? `in ${(duration / 1000).toFixed(2)}s` : ''}`);
53
+ const duration = Date.now() - now;
54
+ tools_1.toast.success(`Build complete in ${(duration / 1000).toFixed(2)}s`);
54
55
  });
55
56
  });
56
57
  }
@@ -21,7 +21,7 @@ const sassLoader = require.resolve('sass-loader');
21
21
  const postcssLoader = require.resolve('postcss-loader');
22
22
  function default_1(_a) {
23
23
  return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
24
- var _b, _c, _d;
24
+ var _b, _c, _d, _e, _f, _g, _h;
25
25
  const customBaseConfig = customConfig.base;
26
26
  const getCustomAliasConfig = () => {
27
27
  const { alias } = customBaseConfig || {};
@@ -33,10 +33,11 @@ function default_1(_a) {
33
33
  }
34
34
  return custAliasConfig;
35
35
  };
36
- const publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
37
- const routerBase = ((_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _b === void 0 ? void 0 : _b.base) || config_1.initConfig.router.base;
36
+ const publicPath = (_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) !== null && _b !== void 0 ? _b : config_1.initConfig.publicPath;
37
+ const routerBase = (_d = (_c = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _c === void 0 ? void 0 : _c.base) !== null && _d !== void 0 ? _d : config_1.initConfig.router.base;
38
+ const cssMode = ((_e = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.cssAuto) !== null && _e !== void 0 ? _e : config_1.initConfig.cssAuto) ? 'css/auto' : 'css';
38
39
  const basicPlugins = [];
39
- const defineConfigData = (_d = (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _c === void 0 ? void 0 : _c.define) !== null && _d !== void 0 ? _d : {};
40
+ const defineConfigData = (_g = (_f = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _f === void 0 ? void 0 : _f.define) !== null && _g !== void 0 ? _g : {};
40
41
  const formatObj = yield (0, config_1.getFormatDefineVars)(defineConfigData);
41
42
  if (Object.keys(formatObj).length !== 0) {
42
43
  basicPlugins.push(new core_1.rspack.DefinePlugin(formatObj));
@@ -95,7 +96,7 @@ function default_1(_a) {
95
96
  oneOf: [
96
97
  {
97
98
  test: /\.css$/,
98
- type: 'css/auto',
99
+ type: cssMode,
99
100
  use: [
100
101
  {
101
102
  loader: postcssLoader,
@@ -109,7 +110,7 @@ function default_1(_a) {
109
110
  },
110
111
  {
111
112
  test: /\.less$/,
112
- type: 'css/auto',
113
+ type: cssMode,
113
114
  use: [
114
115
  {
115
116
  loader: postcssLoader,
@@ -124,7 +125,7 @@ function default_1(_a) {
124
125
  },
125
126
  {
126
127
  test: /\.scss$/,
127
- type: 'css/auto',
128
+ type: cssMode,
128
129
  use: [
129
130
  {
130
131
  loader: postcssLoader,
@@ -186,7 +187,7 @@ function default_1(_a) {
186
187
  },
187
188
  hash: true
188
189
  }),
189
- ...((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins)
190
+ ...((_h = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) !== null && _h !== void 0 ? _h : config_1.initConfig.plugins)
190
191
  ]
191
192
  };
192
193
  });
@@ -24,7 +24,7 @@ const sassLoader = require.resolve('sass-loader');
24
24
  const postcssLoader = require.resolve('postcss-loader');
25
25
  function default_1(_a) {
26
26
  return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
27
- var _b, _c, _d;
27
+ var _b, _c, _d, _e, _f;
28
28
  const customBaseConfig = customConfig.base;
29
29
  const getCustomAliasConfig = () => {
30
30
  const { alias } = customBaseConfig || {};
@@ -36,10 +36,10 @@ function default_1(_a) {
36
36
  }
37
37
  return custAliasConfig;
38
38
  };
39
- const publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
40
- const routerBase = ((_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _b === void 0 ? void 0 : _b.base) || config_1.initConfig.router.base;
39
+ const publicPath = (_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) !== null && _b !== void 0 ? _b : config_1.initConfig.publicPath;
40
+ const routerBase = (_d = (_c = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _c === void 0 ? void 0 : _c.base) !== null && _d !== void 0 ? _d : config_1.initConfig.router.base;
41
41
  const basicPlugins = [];
42
- const defineConfigData = (_d = (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _c === void 0 ? void 0 : _c.define) !== null && _d !== void 0 ? _d : {};
42
+ const defineConfigData = (_e = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.define) !== null && _e !== void 0 ? _e : {};
43
43
  const formatObj = yield (0, config_1.getFormatDefineVars)(defineConfigData);
44
44
  if (Object.keys(formatObj).length !== 0) {
45
45
  basicPlugins.push(new core_1.DefinePlugin(formatObj));
@@ -255,7 +255,7 @@ function default_1(_a) {
255
255
  extensions: ['.ts', '.js', '.vue', '.json'],
256
256
  alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), vue: 'vue/dist/vue.esm-bundler.js', 'vue-router': path_1.default.dirname(require.resolve('vue-router')), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
257
257
  },
258
- externals: customConfig.base.externals,
258
+ externals: customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.externals,
259
259
  plugins: [
260
260
  ...basicPlugins,
261
261
  new core_1.CssExtractRspackPlugin({
@@ -278,7 +278,7 @@ function default_1(_a) {
278
278
  },
279
279
  hash: true
280
280
  }),
281
- ...((customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) || config_1.initConfig.plugins)
281
+ ...((_f = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.plugins) !== null && _f !== void 0 ? _f : config_1.initConfig.plugins)
282
282
  ]
283
283
  };
284
284
  });
@@ -100,7 +100,7 @@ function default_1(options) {
100
100
  new core_1.rspack.CopyRspackPlugin({
101
101
  patterns: [
102
102
  ...(isPublicDirExist ? [path_1.default.join(projectPath, '/public')] : []),
103
- ...copyConfig
103
+ ...(copyConfig || [])
104
104
  ]
105
105
  })
106
106
  ]
@@ -29,6 +29,7 @@ export interface GlobalSwicoConfigType {
29
29
  devtool?: string;
30
30
  externals?: any;
31
31
  router?: ConfigRouterType;
32
+ cssAuto?: boolean;
32
33
  }
33
34
  export interface GlobalData {
34
35
  templateType?: GlobalSwicoConfigType['template'];
@@ -37,7 +38,7 @@ export interface GlobalData {
37
38
  templatePath: string;
38
39
  env?: 'dev' | 'prod';
39
40
  customConfig: {
40
- base: Pick<GlobalSwicoConfigType, 'plugins' | 'publicPath' | 'alias' | 'define' | 'devtool' | 'externals' | 'router' | 'template'>;
41
+ base: Pick<GlobalSwicoConfigType, 'plugins' | 'publicPath' | 'alias' | 'define' | 'devtool' | 'externals' | 'router' | 'template' | 'cssAuto'>;
41
42
  dev: Pick<GlobalSwicoConfigType, 'plugins' | 'proxy' | 'https' | 'devtool' | 'router'>;
42
43
  prod: Pick<GlobalSwicoConfigType, 'plugins' | 'console' | 'copy' | 'devtool' | 'router'>;
43
44
  };
@@ -77,7 +77,8 @@ const getProjectConfig = (env) => __awaiter(void 0, void 0, void 0, function* ()
77
77
  'devtool',
78
78
  'externals',
79
79
  'router',
80
- 'template'
80
+ 'template',
81
+ 'cssAuto'
81
82
  ];
82
83
  configFileName = 'swico.ts';
83
84
  break;
@@ -266,6 +267,7 @@ const getFormatDefineVars = (defineVarsConfigData) => __awaiter(void 0, void 0,
266
267
  exports.getFormatDefineVars = getFormatDefineVars;
267
268
  exports.initConfig = {
268
269
  console: true,
270
+ cssAuto: true,
269
271
  plugins: [],
270
272
  publicPath: '/',
271
273
  proxy: undefined,