@salty-css/core 0.1.0-alpha.13 → 0.1.0-alpha.15
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/main.cjs +6 -3
- package/bin/main.js +6 -3
- package/compiler/salty-compiler.cjs +3 -1
- package/compiler/salty-compiler.d.ts +6 -1
- package/compiler/salty-compiler.js +3 -1
- package/package.json +1 -1
package/bin/main.cjs
CHANGED
|
@@ -145,13 +145,16 @@ const buildContext = async (opts) => {
|
|
|
145
145
|
};
|
|
146
146
|
};
|
|
147
147
|
const registerBuildCommand = (program, defaultProject) => {
|
|
148
|
-
program.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.").option("--watch", "Watch for changes and rebuild the project.").action(async function(_dir = defaultProject) {
|
|
148
|
+
program.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.").option("--watch", "Watch for changes and rebuild the project.").option("--mode <mode>", 'Build mode: "production" or "development". Defaults to NODE_ENV-based detection.').action(async function(_dir = defaultProject) {
|
|
149
149
|
compiler_saltyCompiler.logger.info("Building the Salty-CSS project...");
|
|
150
|
-
const { dir = _dir, watch } = this.opts();
|
|
150
|
+
const { dir = _dir, watch, mode } = this.opts();
|
|
151
|
+
if (mode !== void 0 && mode !== "production" && mode !== "development") {
|
|
152
|
+
return compiler_saltyCompiler.logError(`Invalid --mode "${mode}". Expected "production" or "development".`);
|
|
153
|
+
}
|
|
151
154
|
const resolved = dir ?? await getDefaultProject();
|
|
152
155
|
if (!resolved) return compiler_saltyCompiler.logError("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
|
|
153
156
|
const projectDir = resolveProjectDir(resolved);
|
|
154
|
-
const compiler = new compiler_saltyCompiler.SaltyCompiler(projectDir);
|
|
157
|
+
const compiler = new compiler_saltyCompiler.SaltyCompiler(projectDir, { mode });
|
|
155
158
|
await compiler.generateCss();
|
|
156
159
|
if (watch) {
|
|
157
160
|
compiler_saltyCompiler.logger.info("Watching for changes in the project directory...");
|
package/bin/main.js
CHANGED
|
@@ -142,13 +142,16 @@ const buildContext = async (opts) => {
|
|
|
142
142
|
};
|
|
143
143
|
};
|
|
144
144
|
const registerBuildCommand = (program, defaultProject) => {
|
|
145
|
-
program.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.").option("--watch", "Watch for changes and rebuild the project.").action(async function(_dir = defaultProject) {
|
|
145
|
+
program.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.").option("--watch", "Watch for changes and rebuild the project.").option("--mode <mode>", 'Build mode: "production" or "development". Defaults to NODE_ENV-based detection.').action(async function(_dir = defaultProject) {
|
|
146
146
|
logger.info("Building the Salty-CSS project...");
|
|
147
|
-
const { dir = _dir, watch: watch$1 } = this.opts();
|
|
147
|
+
const { dir = _dir, watch: watch$1, mode } = this.opts();
|
|
148
|
+
if (mode !== void 0 && mode !== "production" && mode !== "development") {
|
|
149
|
+
return logError(`Invalid --mode "${mode}". Expected "production" or "development".`);
|
|
150
|
+
}
|
|
148
151
|
const resolved = dir ?? await getDefaultProject();
|
|
149
152
|
if (!resolved) return logError("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
|
|
150
153
|
const projectDir = resolveProjectDir(resolved);
|
|
151
|
-
const compiler = new SaltyCompiler(projectDir);
|
|
154
|
+
const compiler = new SaltyCompiler(projectDir, { mode });
|
|
152
155
|
await compiler.generateCss();
|
|
153
156
|
if (watch$1) {
|
|
154
157
|
logger.info("Watching for changes in the project directory...");
|
|
@@ -111,7 +111,7 @@ const saltyReset = {
|
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
class SaltyCompiler {
|
|
114
|
-
constructor(projectRootDir) {
|
|
114
|
+
constructor(projectRootDir, options = {}) {
|
|
115
115
|
__publicField(this, "importFile", (path2) => {
|
|
116
116
|
const now = Date.now();
|
|
117
117
|
return import(
|
|
@@ -691,11 +691,13 @@ ${newContent}
|
|
|
691
691
|
});
|
|
692
692
|
});
|
|
693
693
|
this.projectRootDir = projectRootDir;
|
|
694
|
+
this.options = options;
|
|
694
695
|
if (typeof process === "undefined") {
|
|
695
696
|
throw new Error("SaltyServer can only be used in a Node.js environment.");
|
|
696
697
|
}
|
|
697
698
|
}
|
|
698
699
|
get isProduction() {
|
|
700
|
+
if (this.options.mode) return this.options.mode === "production";
|
|
699
701
|
try {
|
|
700
702
|
return process.env["NODE_ENV"] !== "development";
|
|
701
703
|
} catch {
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { CachedConfig, SaltyConfig } from '../config';
|
|
2
|
+
export type SaltyCompilerMode = 'production' | 'development';
|
|
3
|
+
export interface SaltyCompilerOptions {
|
|
4
|
+
mode?: SaltyCompilerMode;
|
|
5
|
+
}
|
|
2
6
|
export declare class SaltyCompiler {
|
|
3
7
|
projectRootDir: string;
|
|
8
|
+
private options;
|
|
4
9
|
importFile: (path: string) => Promise<any>;
|
|
5
10
|
private cache;
|
|
6
|
-
constructor(projectRootDir: string);
|
|
11
|
+
constructor(projectRootDir: string, options?: SaltyCompilerOptions);
|
|
7
12
|
get isProduction(): boolean;
|
|
8
13
|
/**
|
|
9
14
|
* Locate and read the .saltyrc.json file starting from the current directory and moving up the directory tree.
|
|
@@ -91,7 +91,7 @@ const saltyReset = {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
class SaltyCompiler {
|
|
94
|
-
constructor(projectRootDir) {
|
|
94
|
+
constructor(projectRootDir, options = {}) {
|
|
95
95
|
__publicField(this, "importFile", (path) => {
|
|
96
96
|
const now = Date.now();
|
|
97
97
|
return import(
|
|
@@ -671,11 +671,13 @@ ${newContent}
|
|
|
671
671
|
});
|
|
672
672
|
});
|
|
673
673
|
this.projectRootDir = projectRootDir;
|
|
674
|
+
this.options = options;
|
|
674
675
|
if (typeof process === "undefined") {
|
|
675
676
|
throw new Error("SaltyServer can only be used in a Node.js environment.");
|
|
676
677
|
}
|
|
677
678
|
}
|
|
678
679
|
get isProduction() {
|
|
680
|
+
if (this.options.mode) return this.options.mode === "production";
|
|
679
681
|
try {
|
|
680
682
|
return process.env["NODE_ENV"] !== "development";
|
|
681
683
|
} catch {
|