maxa-cli
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -8,55 +8,172 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | ||
const MAIN_PLUGINS = [ | ||
new ForkTsCheckerWebpackPlugin(), | ||
new HtmlWebpackPlugin({ | ||
filename: "index.html", | ||
template: "app/index.html", | ||
favicon: "app/favicon.ico", | ||
removeComments: true, | ||
collapseWhitespace: true, | ||
removeRedundantAttributes: true, | ||
useShortDoctype: true, | ||
removeEmptyAttributes: true, | ||
removeStyleLinkTypeAttributes: true, | ||
keepClosingSlash: true, | ||
minifyJS: true, | ||
minifyCSS: true, | ||
minifyURLs: true, | ||
}), | ||
new MiniCssExtractPlugin({ | ||
filename: "static/css/[name].style.dev.css", | ||
chunkFilename: "static/css/[name].dev.chunk.css", | ||
}), | ||
]; | ||
const OPTIMIZATION = { | ||
runtimeChunk: "single", | ||
minimize: true, | ||
minimizer: [ | ||
new TerserPlugin({ | ||
terserOptions: { | ||
parse: { | ||
ecma: 8, | ||
}, | ||
compress: { | ||
ecma: 5, | ||
warnings: false, | ||
comparisons: false, | ||
inline: 2, | ||
}, | ||
mangle: { | ||
safari10: true, | ||
}, | ||
module: false, | ||
output: { | ||
ecma: 5, | ||
comments: false, | ||
ascii_only: true, | ||
}, | ||
const config = (isDevelopment, outDir) => { | ||
const fileName = isDevelopment === true ? "dev" : "[contenthash:8]"; | ||
return { | ||
mode: "production", | ||
entry: { | ||
main: "./src/Main.ts", | ||
vender: "maxa", | ||
}, | ||
output: { | ||
path: path.resolve("./", isDevelopment === true ? "/app" : "/" + outDir), | ||
filename: "static/js/[name]." + fileName + ".js", | ||
chunkFilename: "[id]." + fileName + ".js", | ||
}, | ||
devtool: isDevelopment === true ? "eval-cheap-module-source-map" : "none", | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?/, | ||
use: { | ||
loader: "ts-loader", | ||
options: { | ||
transpileOnly: true, | ||
happyPackMode: true, | ||
}, | ||
}, | ||
}, //Typescript | ||
{ | ||
test: /\.(s(a|c)ss)$/, | ||
use: [ | ||
MiniCssExtractPlugin.loader, | ||
{ | ||
loader: "css-loader", | ||
options: { | ||
url: true, | ||
sourceMap: isDevelopment === true ? true : false, | ||
import: true, | ||
}, | ||
}, | ||
{ | ||
loader: "sass-loader", | ||
options: { | ||
sourceMap: isDevelopment === true ? true : false, | ||
}, | ||
}, | ||
], | ||
}, //Sass | ||
{ | ||
test: /\.svg$/, | ||
loader: "svg-url-loader", | ||
options: { | ||
limit: 10 * 1024, | ||
noquotes: true, | ||
}, | ||
}, //SVG | ||
{ | ||
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/], | ||
loader: "url-loader", | ||
options: { | ||
limit: 10 * 1024, | ||
name: "static/media/[name].[hash:8].[ext]", | ||
}, | ||
}, //Images | ||
{ | ||
test: /\.(woff(2)?|webp|ico|ttf|eot|json)$/, | ||
loader: "file-loader", | ||
options: { | ||
name: "static/media/[name].[hash:8].[ext]", | ||
}, | ||
type: "asset/resource", | ||
}, //Files | ||
], | ||
}, | ||
cache: { | ||
type: "filesystem", | ||
compression: "gzip", | ||
}, | ||
performance: { | ||
hints: false, | ||
maxEntrypointSize: 512000, | ||
maxAssetSize: 512000, | ||
}, | ||
resolve: { | ||
extensions: [".tsx", ".ts", ".js"], | ||
}, | ||
plugins: [ | ||
function () { | ||
if (isDevelopment === false) { | ||
return new WebpackObfuscator({ | ||
compact: true, | ||
controlFlowFlattening: false, | ||
deadCodeInjection: false, | ||
debugProtection: false, | ||
debugProtectionInterval: false, | ||
disableConsoleOutput: false, | ||
identifierNamesGenerator: "hexadecimal", | ||
log: false, | ||
numbersToExpressions: true, | ||
renameGlobals: false, | ||
selfDefending: true, | ||
simplify: true, | ||
splitStrings: false, | ||
stringArray: true, | ||
stringArrayEncoding: ["base64"], | ||
stringArrayIndexShift: true, | ||
stringArrayRotate: true, | ||
stringArrayShuffle: true, | ||
stringArrayWrappersCount: 1, | ||
stringArrayWrappersChainedCalls: true, | ||
stringArrayWrappersParametersMaxCount: 2, | ||
stringArrayWrappersType: "variable", | ||
stringArrayThreshold: 0.75, | ||
unicodeEscapeSequence: false, | ||
}); | ||
} | ||
}, | ||
}), | ||
], | ||
splitChunks: { | ||
chunks: "all", | ||
}, | ||
new ForkTsCheckerWebpackPlugin(), | ||
new HtmlWebpackPlugin({ | ||
filename: "index.html", | ||
template: "app/index.html", | ||
favicon: "app/favicon.ico", | ||
removeComments: true, | ||
collapseWhitespace: true, | ||
removeRedundantAttributes: true, | ||
useShortDoctype: true, | ||
removeEmptyAttributes: true, | ||
removeStyleLinkTypeAttributes: true, | ||
keepClosingSlash: true, | ||
minifyJS: true, | ||
minifyCSS: true, | ||
minifyURLs: true, | ||
}), | ||
new MiniCssExtractPlugin({ | ||
filename: "static/css/[name]." + filename + ".css", | ||
chunkFilename: "static/css/[name]." + filename + ".chunk.css", | ||
}), | ||
], | ||
optimization: { | ||
runtimeChunk: { | ||
name: entrypoint => `runtime-${entrypoint.name}`, | ||
}, | ||
minimize: true, | ||
minimizer: [ | ||
new TerserPlugin({ | ||
terserOptions: { | ||
parse: { | ||
ecma: 8, | ||
}, | ||
compress: { | ||
ecma: 5, | ||
warnings: false, | ||
comparisons: false, | ||
inline: 2, | ||
}, | ||
mangle: { | ||
safari10: true, | ||
}, | ||
module: false, | ||
output: { | ||
ecma: 5, | ||
comments: false, | ||
ascii_only: true, | ||
}, | ||
}, | ||
}), | ||
], | ||
splitChunks: { | ||
chunks: "all", | ||
}, | ||
}, | ||
}; | ||
}; | ||
@@ -83,134 +200,5 @@ | ||
const IMAGES = [ | ||
{ | ||
test: /\.svg/, | ||
use: { | ||
loader: "svg-url-loader", | ||
options: { | ||
encoding: "base64", | ||
}, | ||
}, | ||
}, //Svg | ||
{ | ||
test: [/\.png$/], | ||
type: "asset/inline", | ||
}, //png | ||
{ | ||
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/,/\.webp$/], | ||
loader: "url-loader", | ||
options: { | ||
limit: 10000, | ||
name: "static/media/[name].[hash:8].[ext]", | ||
}, | ||
}, | ||
{ | ||
test:/\.(woff(2)?|ttf|eot)$/, | ||
loader: "file-loader", | ||
options: { | ||
name: "static/media/[name].[hash].[ext]", | ||
}, | ||
type: "asset/resource", | ||
}, //Files | ||
]; | ||
const PRO = { | ||
RULES: [ | ||
{ | ||
test: /\.tsx?/, | ||
use: { | ||
loader: "ts-loader", | ||
options: { | ||
transpileOnly: true, | ||
happyPackMode: true, | ||
}, | ||
}, | ||
}, | ||
{ | ||
test: /\.(s(a|c)ss)$/, | ||
use: [ | ||
MiniCssExtractPlugin.loader, | ||
{ | ||
loader: "css-loader", | ||
options: { | ||
url: true, | ||
import: true, | ||
}, | ||
}, | ||
"sass-loader", | ||
], | ||
}, | ||
...IMAGES, | ||
], | ||
PLUGINS: [ | ||
new WebpackObfuscator({ | ||
compact: true, | ||
controlFlowFlattening: false, | ||
deadCodeInjection: false, | ||
debugProtection: false, | ||
debugProtectionInterval: false, | ||
disableConsoleOutput: false, | ||
identifierNamesGenerator: "hexadecimal", | ||
log: false, | ||
numbersToExpressions: true, | ||
renameGlobals: false, | ||
selfDefending: true, | ||
simplify: true, | ||
splitStrings: false, | ||
stringArray: true, | ||
stringArrayEncoding: ["base64"], | ||
stringArrayIndexShift: true, | ||
stringArrayRotate: true, | ||
stringArrayShuffle: true, | ||
stringArrayWrappersCount: 1, | ||
stringArrayWrappersChainedCalls: true, | ||
stringArrayWrappersParametersMaxCount: 2, | ||
stringArrayWrappersType: "variable", | ||
stringArrayThreshold: 0.75, | ||
unicodeEscapeSequence: false, | ||
}), | ||
], | ||
}; | ||
const DEV = { | ||
RULES: [ | ||
{ | ||
test: /\.tsx?/, | ||
use: { | ||
loader: "ts-loader", | ||
options: { | ||
transpileOnly: true, | ||
happyPackMode: true, | ||
}, | ||
}, | ||
}, //Typescript | ||
{ | ||
test: /\.(s(a|c)ss)$/, | ||
use: [ | ||
MiniCssExtractPlugin.loader, | ||
{ | ||
loader: "css-loader", | ||
options: { | ||
url: true, | ||
sourceMap: true, | ||
import: true, | ||
}, | ||
}, | ||
{ | ||
loader: "sass-loader", | ||
options: { | ||
sourceMap: true, | ||
}, | ||
}, | ||
], | ||
}, //Sass | ||
...IMAGES, | ||
], | ||
}; | ||
module.exports = { | ||
MAIN_PLUGINS, | ||
OPTIMIZATION, | ||
config, | ||
DEV_SERVER, | ||
PRO, | ||
DEV, | ||
}; |
#!/usr/bin/env node | ||
const { _Error, _Success, _Info } = require("./Shared.js"); | ||
const { _Error, _Info } = require("./Shared.js"); | ||
const { CheckFiles } = require("./Shared"); | ||
const web = require("./Web"); | ||
const fs = require("fs"); | ||
const { createFiles } = require("./Create"); | ||
const { exec } = require("child_process"); | ||
const { start, build } = require("./Scripts"); | ||
const args = process.argv.splice(process.execArgv.length + 2); | ||
@@ -15,3 +14,3 @@ | ||
if (args[1] === undefined) { | ||
web.prototype.start(3000); | ||
start(5000); | ||
} else if (args[1].length > 3) { | ||
@@ -21,14 +20,9 @@ if (isNaN(args[1])) { | ||
} else { | ||
web.prototype.start(args[1]); | ||
start(args[1]); | ||
} | ||
} else if (args[1].length < 3) { | ||
_Error("===> port more than 3 numbers"); | ||
} else if (args[1].length >= 3) { | ||
_Error("===> port sholud be more than 3 numbers"); | ||
} | ||
}); | ||
break; | ||
case "compile": | ||
CheckFiles(() => { | ||
web.prototype.compile(); | ||
}); | ||
break; | ||
case "create": | ||
@@ -52,3 +46,3 @@ if (fs.existsSync("./" + args[1] + "/package.json")) { | ||
CheckFiles(() => { | ||
web.prototype.build(args[1]); | ||
build(args[1]); | ||
}); | ||
@@ -55,0 +49,0 @@ break; |
{ | ||
"name": "maxa-cli", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "The Official Maxa CLI Tools to build, deploy and manage maxa-based apps", | ||
@@ -5,0 +5,0 @@ "main": "bin/Index.js", |
3
1
29915
18
607