create-nodality 1.0.0-beta.2 → 1.0.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.
Files changed (2) hide show
  1. package/bin/index.js +45 -2
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -35,10 +35,18 @@ function createProject(projectName) {
35
35
  version: "1.0.0",
36
36
  type: "module",
37
37
  scripts: {
38
- start: "serve ."
38
+ build: "webpack",
39
+ start: "serve dist"
39
40
  },
40
41
  dependencies: {
41
42
  nodality: "^1.0.0-beta.4"
43
+ },
44
+ devDependencies: {
45
+ webpack: "^5.0.0",
46
+ "webpack-cli": "^5.0.0",
47
+ "babel-loader": "^9.0.0",
48
+ "@babel/core": "^7.0.0",
49
+ "@babel/preset-env": "^7.0.0"
42
50
  }
43
51
  };
44
52
 
@@ -49,9 +57,44 @@ function createProject(projectName) {
49
57
  console.log("Installing dependencies...");
50
58
  execSync(`npm install`, { cwd: projectPath, stdio: "inherit" });
51
59
 
60
+ // Create webpack.config.js
61
+ const webpackConfig = `
62
+ const path = require('path');
63
+
64
+ module.exports = {
65
+ mode: 'development',
66
+ entry: './main.js',
67
+ output: {
68
+ filename: 'bundle.js',
69
+ path: path.resolve(process.cwd(), 'dist'),
70
+ },
71
+ module: {
72
+ rules: [
73
+ {
74
+ test: /\\.m?js$/,
75
+ exclude: /node_modules/,
76
+ use: {
77
+ loader: 'babel-loader',
78
+ options: {
79
+ presets: ['@babel/preset-env']
80
+ }
81
+ }
82
+ }
83
+ ]
84
+ }
85
+ };
86
+ `;
87
+ writeFileSync(resolve(projectPath, "webpack.config.js"), webpackConfig.trim());
88
+ console.log("Created webpack.config.js");
89
+
90
+ // Build project using webpack
91
+ console.log("Building with webpack...");
92
+ execSync(`npx webpack`, { cwd: projectPath, stdio: "inherit" });
93
+
52
94
  console.log("\nAll done! Run:\n");
53
95
  console.log(` cd ${projectName}`);
54
- console.log(" npm start\n");
96
+ console.log(" npm run build # Rebuild your project");
97
+ console.log(" npm start # Serve your project\n");
55
98
  }
56
99
 
57
100
  const args = process.argv.slice(2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nodality",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "Project scaffolding tool for Nodality library",
5
5
  "bin": {
6
6
  "create-nodality": "./bin/index.js"