@vnejs/build 0.0.5 → 0.0.6

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.5",
3
+ "version": "0.0.6",
4
4
  "description": "Build tools for @vnejs",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -16,6 +16,28 @@
16
16
  "author": "",
17
17
  "license": "ISC",
18
18
  "dependencies": {
19
- "lodash.merge": "4.6.2"
19
+ "lodash.merge": "4.6.2",
20
+ "webpack": "5.88.1",
21
+ "html-webpack-plugin": "4.5.2",
22
+ "mini-css-extract-plugin": "1.1.1",
23
+ "regenerator-runtime": "0.13.7",
24
+ "setimmediate": "1.0.5",
25
+ "style-loader": "2.0.0",
26
+ "stylus": "0.59.0",
27
+ "stylus-loader": "3.0.2",
28
+ "css-loader": "5.0.0",
29
+ "react": "16.14.0",
30
+ "react-dom": "16.14.0",
31
+ "@loadable/babel-plugin": "5.13.2",
32
+ "@loadable/webpack-plugin": "5.14.0",
33
+ "babel-loader": "8.1.0",
34
+ "babel-plugin-module-resolver": "4.0.0",
35
+ "babel-plugin-transform-react-remove-prop-types": "0.4.24",
36
+ "base64-inline-loader": "2.0.1",
37
+ "@babel/core": "7.12.3",
38
+ "@babel/plugin-proposal-class-properties": "7.12.1",
39
+ "@babel/plugin-syntax-dynamic-import": "7.8.3",
40
+ "@babel/preset-env": "7.12.1",
41
+ "@babel/preset-react": "7.12.1"
20
42
  }
21
43
  }
package/src/cli.js CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  const { Command } = require("commander");
4
4
 
5
- const dataAction = require("./data");
6
-
7
5
  const packageJson = require("../package.json");
8
6
 
9
7
  const program = new Command();
@@ -14,12 +12,12 @@ program
14
12
  .command("data")
15
13
  .option("-w, --watch", "watch mode", false)
16
14
  .option("-q, --quiet", "no console mode", false)
17
- .action(dataAction(process.env.PWD));
15
+ .action(require("./data")(process.env.PWD));
18
16
 
19
17
  program
20
- .command("bundle")
18
+ .command("client")
21
19
  .option("-w, --watch", "watch mode", false)
22
20
  .option("-q, --quiet", "no console mode", false)
23
- .action(dataAction(process.env.PWD));
21
+ .action(require("./client")(process.env.PWD));
24
22
 
25
23
  program.parse();
@@ -0,0 +1,9 @@
1
+ const webpack = require("webpack");
2
+
3
+ module.exports = (rootDir) => (options) =>
4
+ webpack(require("./webpack.config")(rootDir, options), (err, stats) => {
5
+ if (err || stats.hasErrors()) {
6
+ stats.hasErrors() && console.error(stats.toJson().errors);
7
+ stats.hasWarnings() && console.warn(stats.toJson().warnings);
8
+ }
9
+ });
@@ -0,0 +1,97 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const webpack = require("webpack");
4
+ const HtmlWebpackPlugin = require("html-webpack-plugin");
5
+ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
6
+
7
+ module.exports = (rootPath, options) => {
8
+ const distPath = path.join(rootPath, "dist");
9
+ const gamePath = path.join(rootPath, "game");
10
+ const nodeModulesPath = path.join(__dirname, "..", "..", "node_modules");
11
+ const entry = [path.join(rootPath, "client", "index.js")];
12
+ const isDev = process.env.NODE_ENV === "development";
13
+
14
+ fs.readdirSync(gamePath).forEach((modDir) => {
15
+ const scriptPath = path.join(gamePath, modDir, "scripts", "index.js");
16
+
17
+ fs.existsSync(scriptPath) && entry.push(scriptPath);
18
+ });
19
+
20
+ return {
21
+ watch: options.watch,
22
+ mode: isDev ? "development" : "production",
23
+ target: "web",
24
+ entry: {
25
+ index: { import: entry, chunkLoading: false, dependOn: "vendors" },
26
+ vendors: [
27
+ `${nodeModulesPath}/regenerator-runtime`,
28
+ `${nodeModulesPath}/setimmediate`,
29
+ `${nodeModulesPath}/react`,
30
+ `${nodeModulesPath}/react-dom`,
31
+ ],
32
+ },
33
+ optimization: { minimize: true },
34
+ resolve: {
35
+ extensions: [".js", ".jsx", ".styl", ".css"],
36
+ alias: {
37
+ "@Vne/core": path.resolve(rootPath, "client/engine/core"),
38
+ "@Vne/modules": path.resolve(rootPath, "client/engine/modules"),
39
+ "@Vne/bundles": path.resolve(rootPath, "client/engine/bundles"),
40
+ },
41
+ },
42
+ output: { path: distPath, filename: "[name].[hash].js" },
43
+ plugins: [
44
+ new webpack.DefinePlugin({
45
+ "process.env.NODE_ENV": `"${isDev ? "development" : "production"}"`,
46
+ }),
47
+ new HtmlWebpackPlugin({ filename: "index.html", template: path.join(rootPath, "client", "index.html") }),
48
+ new MiniCssExtractPlugin({ filename: path.join(distPath, "dist", "index.css") }),
49
+ ],
50
+
51
+ module: {
52
+ rules: [
53
+ {
54
+ test: /\.m?(t|j)sx?$/,
55
+ exclude: /node_modules/,
56
+ use: {
57
+ loader: `${nodeModulesPath}/babel-loader`,
58
+ options: {
59
+ plugins: [
60
+ `${nodeModulesPath}/@babel/plugin-syntax-dynamic-import`,
61
+ `${nodeModulesPath}/@babel/plugin-proposal-class-properties`,
62
+ `${nodeModulesPath}/@loadable/babel-plugin`,
63
+ ],
64
+ presets: [
65
+ `${nodeModulesPath}/@babel/preset-react`,
66
+ [
67
+ `${nodeModulesPath}/@babel/preset-env`,
68
+ { useBuiltIns: "entry", corejs: "core-js@3", modules: "commonjs" },
69
+ ],
70
+ ],
71
+ cacheDirectory: true,
72
+ caller: { target: "clientside", name: "babel-loader" },
73
+ },
74
+ },
75
+ },
76
+ {
77
+ test: /\.css$/,
78
+ use: [
79
+ // MiniCssExtractPlugin.loader,
80
+ { loader: `${nodeModulesPath}/style-loader` },
81
+ { loader: `${nodeModulesPath}/css-loader` },
82
+ ],
83
+ },
84
+ {
85
+ test: /\.styl$/,
86
+ use: [
87
+ // MiniCssExtractPlugin.loader,
88
+ { loader: `${nodeModulesPath}/style-loader` },
89
+ { loader: `${nodeModulesPath}/css-loader` },
90
+ { loader: `${nodeModulesPath}/stylus-loader` },
91
+ ],
92
+ },
93
+ { test: /\.(jpe?g|png|ttf|gif|eot|svg|woff)$/, use: [{ loader: `${nodeModulesPath}/base64-inline-loader` }] },
94
+ ],
95
+ },
96
+ };
97
+ };
package/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  module.exports = {
2
2
  buildData: (rootDir, watch = false) => require("./data")(rootDir)({ watch }),
3
+ buildClient: (rootDir, watch = false) => require("./client")(rootDir)({ watch }),
3
4
  };