@vnejs/build 0.0.14 → 0.0.16

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": "@vnejs/build",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "Build tools for @vnejs",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -16,6 +16,7 @@
16
16
  "author": "",
17
17
  "license": "ISC",
18
18
  "dependencies": {
19
+ "@bem-react/classname": "1.5.12",
19
20
  "lodash.merge": "4.6.2",
20
21
  "webpack": "^5.88.1",
21
22
  "html-webpack-plugin": "4.5.2",
@@ -4,12 +4,43 @@ const webpack = require("webpack");
4
4
  const HtmlWebpackPlugin = require("html-webpack-plugin");
5
5
  const MiniCssExtractPlugin = require("mini-css-extract-plugin");
6
6
 
7
+ const isDev = process.env.NODE_ENV === "development";
8
+
9
+ const getScriptLoader = (nodeModulesPath) => ({
10
+ loader: `${nodeModulesPath}/babel-loader`,
11
+ options: {
12
+ plugins: [
13
+ `${nodeModulesPath}/@babel/plugin-syntax-dynamic-import`,
14
+ `${nodeModulesPath}/@babel/plugin-proposal-class-properties`,
15
+ `${nodeModulesPath}/@loadable/babel-plugin`,
16
+ ],
17
+ presets: [
18
+ `${nodeModulesPath}/@babel/preset-react`,
19
+ [`${nodeModulesPath}/@babel/preset-env`, { useBuiltIns: "entry", corejs: "core-js@3", modules: "commonjs" }],
20
+ ],
21
+ cacheDirectory: true,
22
+ caller: { target: "clientside", name: "babel-loader" },
23
+ },
24
+ });
25
+
26
+ const getCssLoader = (nodeModulesPath) => [
27
+ // MiniCssExtractPlugin.loader,
28
+ { loader: `${nodeModulesPath}/style-loader` },
29
+ { loader: `${nodeModulesPath}/css-loader` },
30
+ ];
31
+
32
+ const getStylusLoader = (nodeModulesPath) => [
33
+ // MiniCssExtractPlugin.loader,
34
+ { loader: `${nodeModulesPath}/style-loader` },
35
+ { loader: `${nodeModulesPath}/css-loader` },
36
+ { loader: `${nodeModulesPath}/stylus-loader` },
37
+ ];
38
+
7
39
  module.exports = (rootPath, options) => {
8
40
  const distPath = path.join(rootPath, "dist");
9
41
  const gamePath = path.join(rootPath, "game");
10
42
  const nodeModulesPath = path.join(rootPath, "node_modules");
11
43
  const entry = [path.join(rootPath, "client", "index.js")];
12
- const isDev = process.env.NODE_ENV === "development";
13
44
 
14
45
  fs.readdirSync(gamePath).forEach((modDir) => {
15
46
  const scriptPath = path.join(gamePath, modDir, "scripts", "index.js");
@@ -32,9 +63,8 @@ module.exports = (rootPath, options) => {
32
63
  },
33
64
  optimization: { minimize: true },
34
65
  resolve: {
35
- extensions: [".js", ".jsx", ".styl", ".css"],
66
+ extensions: [".js", ".jsx", ".ts", ".tsx", ".styl", ".css"],
36
67
  alias: {
37
- "@Vne/core": path.resolve(rootPath, "client/engine/core"),
38
68
  "@Vne/modules": path.resolve(rootPath, "client/engine/modules"),
39
69
  "@Vne/bundles": path.resolve(rootPath, "client/engine/bundles"),
40
70
  },
@@ -50,45 +80,10 @@ module.exports = (rootPath, options) => {
50
80
 
51
81
  module: {
52
82
  rules: [
53
- {
54
- test: /\.m?(t|j)sx?$/,
55
- use: {
56
- loader: `${nodeModulesPath}/babel-loader`,
57
- options: {
58
- plugins: [
59
- `${nodeModulesPath}/@babel/plugin-syntax-dynamic-import`,
60
- `${nodeModulesPath}/@babel/plugin-proposal-class-properties`,
61
- `${nodeModulesPath}/@loadable/babel-plugin`,
62
- ],
63
- presets: [
64
- `${nodeModulesPath}/@babel/preset-react`,
65
- [
66
- `${nodeModulesPath}/@babel/preset-env`,
67
- { useBuiltIns: "entry", corejs: "core-js@3", modules: "commonjs" },
68
- ],
69
- ],
70
- cacheDirectory: true,
71
- caller: { target: "clientside", name: "babel-loader" },
72
- },
73
- },
74
- },
75
- {
76
- test: /\.css$/,
77
- use: [
78
- // MiniCssExtractPlugin.loader,
79
- { loader: `${nodeModulesPath}/style-loader` },
80
- { loader: `${nodeModulesPath}/css-loader` },
81
- ],
82
- },
83
- {
84
- test: /\.styl$/,
85
- use: [
86
- // MiniCssExtractPlugin.loader,
87
- { loader: `${nodeModulesPath}/style-loader` },
88
- { loader: `${nodeModulesPath}/css-loader` },
89
- { loader: `${nodeModulesPath}/stylus-loader` },
90
- ],
91
- },
83
+ { test: /\.m?(t|j)sx?$/, exclude: /node_modules/, use: getScriptLoader(nodeModulesPath) },
84
+ { test: /\.m?(t|j)sx?$/, include: /node_modules\/@vnejs/, use: getScriptLoader(nodeModulesPath) },
85
+ { test: /\.css$/, use: getCssLoader(nodeModulesPath) },
86
+ { test: /\.styl$/, use: getStylusLoader(nodeModulesPath) },
92
87
  { test: /\.(jpe?g|png|ttf|gif|eot|svg|woff)$/, use: [{ loader: `${nodeModulesPath}/base64-inline-loader` }] },
93
88
  ],
94
89
  },