create-nodality 1.0.0-beta.2 → 1.0.0-beta.4
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/bin/index.js +49 -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
|
-
|
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,48 @@ 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
|
+
import path from 'path';
|
63
|
+
import { fileURLToPath } from 'url';
|
64
|
+
|
65
|
+
const __filename = fileURLToPath(import.meta.url);
|
66
|
+
const __dirname = path.dirname(__filename);
|
67
|
+
|
68
|
+
export default {
|
69
|
+
mode: 'development',
|
70
|
+
entry: './main.js',
|
71
|
+
output: {
|
72
|
+
filename: 'bundle.js',
|
73
|
+
path: path.resolve(process.cwd(), 'dist'),
|
74
|
+
},
|
75
|
+
module: {
|
76
|
+
rules: [
|
77
|
+
{
|
78
|
+
test: /\.m?js$/,
|
79
|
+
exclude: /node_modules/,
|
80
|
+
use: {
|
81
|
+
loader: 'babel-loader',
|
82
|
+
options: {
|
83
|
+
presets: ['@babel/preset-env'],
|
84
|
+
},
|
85
|
+
},
|
86
|
+
},
|
87
|
+
],
|
88
|
+
},
|
89
|
+
};
|
90
|
+
`;
|
91
|
+
writeFileSync(resolve(projectPath, "webpack.config.js"), webpackConfig.trim());
|
92
|
+
console.log("Created webpack.config.js");
|
93
|
+
|
94
|
+
// Build project using webpack
|
95
|
+
console.log("Building with webpack...");
|
96
|
+
execSync(`npx webpack`, { cwd: projectPath, stdio: "inherit" });
|
97
|
+
|
52
98
|
console.log("\nAll done! Run:\n");
|
53
99
|
console.log(` cd ${projectName}`);
|
54
|
-
console.log(" npm
|
100
|
+
console.log(" npm run build # Rebuild your project");
|
101
|
+
console.log(" npm start # Serve your project\n");
|
55
102
|
}
|
56
103
|
|
57
104
|
const args = process.argv.slice(2);
|