@dcloudio/uni-cli-shared 0.0.1-nvue3.3030820220125001

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 (236) hide show
  1. package/dist/checkUpdate.d.ts +30 -0
  2. package/dist/checkUpdate.js +243 -0
  3. package/dist/constants.d.ts +19 -0
  4. package/dist/constants.js +43 -0
  5. package/dist/deps.d.ts +19 -0
  6. package/dist/deps.js +39 -0
  7. package/dist/easycom.d.ts +29 -0
  8. package/dist/easycom.js +202 -0
  9. package/dist/env/define.d.ts +15 -0
  10. package/dist/env/define.js +45 -0
  11. package/dist/env/index.d.ts +2 -0
  12. package/dist/env/index.js +8 -0
  13. package/dist/env/provide.d.ts +9 -0
  14. package/dist/env/provide.js +24 -0
  15. package/dist/esbuild.d.ts +3 -0
  16. package/dist/esbuild.js +42 -0
  17. package/dist/exports.d.ts +1 -0
  18. package/dist/exports.js +8 -0
  19. package/dist/filter.d.ts +16 -0
  20. package/dist/filter.js +60 -0
  21. package/dist/fs.d.ts +1 -0
  22. package/dist/fs.js +25 -0
  23. package/dist/hbx/alias.d.ts +5 -0
  24. package/dist/hbx/alias.js +75 -0
  25. package/dist/hbx/env.d.ts +6 -0
  26. package/dist/hbx/env.js +44 -0
  27. package/dist/hbx/index.d.ts +3 -0
  28. package/dist/hbx/index.js +36 -0
  29. package/dist/hbx/log.d.ts +6 -0
  30. package/dist/hbx/log.js +99 -0
  31. package/dist/i18n.d.ts +10 -0
  32. package/dist/i18n.js +94 -0
  33. package/dist/index.d.ts +25 -0
  34. package/dist/index.js +40 -0
  35. package/dist/json/app/index.d.ts +3 -0
  36. package/dist/json/app/index.js +17 -0
  37. package/dist/json/app/manifest/arguments.d.ts +2 -0
  38. package/dist/json/app/manifest/arguments.js +36 -0
  39. package/dist/json/app/manifest/confusion.d.ts +4 -0
  40. package/dist/json/app/manifest/confusion.js +77 -0
  41. package/dist/json/app/manifest/defaultManifestJson.d.ts +1 -0
  42. package/dist/json/app/manifest/defaultManifestJson.js +41 -0
  43. package/dist/json/app/manifest/env.d.ts +3 -0
  44. package/dist/json/app/manifest/env.js +24 -0
  45. package/dist/json/app/manifest/i18n.d.ts +1 -0
  46. package/dist/json/app/manifest/i18n.js +14 -0
  47. package/dist/json/app/manifest/index.d.ts +4 -0
  48. package/dist/json/app/manifest/index.js +49 -0
  49. package/dist/json/app/manifest/launchwebview.d.ts +1 -0
  50. package/dist/json/app/manifest/launchwebview.js +32 -0
  51. package/dist/json/app/manifest/merge.d.ts +1 -0
  52. package/dist/json/app/manifest/merge.js +17 -0
  53. package/dist/json/app/manifest/nvue.d.ts +4 -0
  54. package/dist/json/app/manifest/nvue.js +43 -0
  55. package/dist/json/app/manifest/plus.d.ts +1 -0
  56. package/dist/json/app/manifest/plus.js +83 -0
  57. package/dist/json/app/manifest/safearea.d.ts +1 -0
  58. package/dist/json/app/manifest/safearea.js +28 -0
  59. package/dist/json/app/manifest/splashscreen.d.ts +5 -0
  60. package/dist/json/app/manifest/splashscreen.js +44 -0
  61. package/dist/json/app/manifest/statusbar.d.ts +1 -0
  62. package/dist/json/app/manifest/statusbar.js +14 -0
  63. package/dist/json/app/manifest/tabBar.d.ts +1 -0
  64. package/dist/json/app/manifest/tabBar.js +27 -0
  65. package/dist/json/app/manifest/uniApp.d.ts +1 -0
  66. package/dist/json/app/manifest/uniApp.js +19 -0
  67. package/dist/json/app/pages/code.d.ts +3 -0
  68. package/dist/json/app/pages/code.js +44 -0
  69. package/dist/json/app/pages/definePage.d.ts +2 -0
  70. package/dist/json/app/pages/definePage.js +42 -0
  71. package/dist/json/app/pages/index.d.ts +3 -0
  72. package/dist/json/app/pages/index.js +28 -0
  73. package/dist/json/app/pages/uniConfig.d.ts +1 -0
  74. package/dist/json/app/pages/uniConfig.js +69 -0
  75. package/dist/json/app/pages/uniRoutes.d.ts +1 -0
  76. package/dist/json/app/pages/uniRoutes.js +8 -0
  77. package/dist/json/index.d.ts +5 -0
  78. package/dist/json/index.js +17 -0
  79. package/dist/json/json.d.ts +1 -0
  80. package/dist/json/json.js +9 -0
  81. package/dist/json/manifest.d.ts +28 -0
  82. package/dist/json/manifest.js +64 -0
  83. package/dist/json/mp/index.d.ts +4 -0
  84. package/dist/json/mp/index.js +19 -0
  85. package/dist/json/mp/jsonFile.d.ts +23 -0
  86. package/dist/json/mp/jsonFile.js +127 -0
  87. package/dist/json/mp/pages.d.ts +17 -0
  88. package/dist/json/mp/pages.js +126 -0
  89. package/dist/json/mp/project.d.ts +14 -0
  90. package/dist/json/mp/project.js +81 -0
  91. package/dist/json/mp/types.d.ts +118 -0
  92. package/dist/json/mp/types.js +2 -0
  93. package/dist/json/mp/utils.d.ts +3 -0
  94. package/dist/json/mp/utils.js +66 -0
  95. package/dist/json/pages.d.ts +30 -0
  96. package/dist/json/pages.js +383 -0
  97. package/dist/logs/console.d.ts +4 -0
  98. package/dist/logs/console.js +49 -0
  99. package/dist/logs/format.d.ts +11 -0
  100. package/dist/logs/format.js +82 -0
  101. package/dist/logs/index.d.ts +1 -0
  102. package/dist/logs/index.js +7 -0
  103. package/dist/messages/index.d.ts +20 -0
  104. package/dist/messages/index.js +23 -0
  105. package/dist/mp/ast.d.ts +4 -0
  106. package/dist/mp/ast.js +12 -0
  107. package/dist/mp/constants.d.ts +5 -0
  108. package/dist/mp/constants.js +8 -0
  109. package/dist/mp/event.d.ts +5 -0
  110. package/dist/mp/event.js +35 -0
  111. package/dist/mp/externalClasses.d.ts +5 -0
  112. package/dist/mp/externalClasses.js +42 -0
  113. package/dist/mp/imports.d.ts +12 -0
  114. package/dist/mp/imports.js +72 -0
  115. package/dist/mp/index.d.ts +11 -0
  116. package/dist/mp/index.js +38 -0
  117. package/dist/mp/nvue.d.ts +1 -0
  118. package/dist/mp/nvue.js +18 -0
  119. package/dist/mp/plugin.d.ts +2 -0
  120. package/dist/mp/plugin.js +13 -0
  121. package/dist/mp/style.d.ts +1 -0
  122. package/dist/mp/style.js +9 -0
  123. package/dist/mp/tags.d.ts +1 -0
  124. package/dist/mp/tags.js +117 -0
  125. package/dist/mp/template.d.ts +73 -0
  126. package/dist/mp/template.js +73 -0
  127. package/dist/mp/usingComponents.d.ts +65 -0
  128. package/dist/mp/usingComponents.js +402 -0
  129. package/dist/mp/wxs.d.ts +2 -0
  130. package/dist/mp/wxs.js +55 -0
  131. package/dist/platform.d.ts +2 -0
  132. package/dist/platform.js +31 -0
  133. package/dist/postcss/index.d.ts +10 -0
  134. package/dist/postcss/index.js +19 -0
  135. package/dist/postcss/plugins/stylePluginScoped.d.ts +3 -0
  136. package/dist/postcss/plugins/stylePluginScoped.js +176 -0
  137. package/dist/postcss/plugins/uniapp.d.ts +11 -0
  138. package/dist/postcss/plugins/uniapp.js +110 -0
  139. package/dist/preprocess/context.d.ts +3 -0
  140. package/dist/preprocess/context.js +81 -0
  141. package/dist/preprocess/index.d.ts +9 -0
  142. package/dist/preprocess/index.js +28 -0
  143. package/dist/resolve.d.ts +6 -0
  144. package/dist/resolve.js +102 -0
  145. package/dist/scripts.d.ts +10 -0
  146. package/dist/scripts.js +44 -0
  147. package/dist/ssr.d.ts +4 -0
  148. package/dist/ssr.js +20 -0
  149. package/dist/url.d.ts +2 -0
  150. package/dist/url.js +15 -0
  151. package/dist/utils.d.ts +13 -0
  152. package/dist/utils.js +80 -0
  153. package/dist/vite/features.d.ts +41 -0
  154. package/dist/vite/features.js +191 -0
  155. package/dist/vite/index.d.ts +36 -0
  156. package/dist/vite/index.js +17 -0
  157. package/dist/vite/plugins/console.d.ts +8 -0
  158. package/dist/vite/plugins/console.js +42 -0
  159. package/dist/vite/plugins/copy.d.ts +11 -0
  160. package/dist/vite/plugins/copy.js +51 -0
  161. package/dist/vite/plugins/cssScoped.d.ts +6 -0
  162. package/dist/vite/plugins/cssScoped.js +54 -0
  163. package/dist/vite/plugins/dynamicImportPolyfill.d.ts +2 -0
  164. package/dist/vite/plugins/dynamicImportPolyfill.js +15 -0
  165. package/dist/vite/plugins/index.d.ts +10 -0
  166. package/dist/vite/plugins/index.js +32 -0
  167. package/dist/vite/plugins/inject.d.ts +12 -0
  168. package/dist/vite/plugins/inject.js +207 -0
  169. package/dist/vite/plugins/jsonJs.d.ts +3 -0
  170. package/dist/vite/plugins/jsonJs.js +52 -0
  171. package/dist/vite/plugins/mainJs.d.ts +2 -0
  172. package/dist/vite/plugins/mainJs.js +29 -0
  173. package/dist/vite/plugins/vitejs/config.d.ts +1 -0
  174. package/dist/vite/plugins/vitejs/config.js +2 -0
  175. package/dist/vite/plugins/vitejs/constants.d.ts +8 -0
  176. package/dist/vite/plugins/vitejs/constants.js +11 -0
  177. package/dist/vite/plugins/vitejs/index.d.ts +1 -0
  178. package/dist/vite/plugins/vitejs/index.js +2 -0
  179. package/dist/vite/plugins/vitejs/plugin.d.ts +1 -0
  180. package/dist/vite/plugins/vitejs/plugin.js +2 -0
  181. package/dist/vite/plugins/vitejs/plugins/asset.d.ts +40 -0
  182. package/dist/vite/plugins/vitejs/plugins/asset.js +270 -0
  183. package/dist/vite/plugins/vitejs/plugins/css.d.ts +48 -0
  184. package/dist/vite/plugins/vitejs/plugins/css.js +760 -0
  185. package/dist/vite/plugins/vitejs/server/moduleGraph.d.ts +1 -0
  186. package/dist/vite/plugins/vitejs/server/moduleGraph.js +2 -0
  187. package/dist/vite/plugins/vitejs/utils.d.ts +29 -0
  188. package/dist/vite/plugins/vitejs/utils.js +129 -0
  189. package/dist/vite/utils/ast.d.ts +17 -0
  190. package/dist/vite/utils/ast.js +85 -0
  191. package/dist/vite/utils/index.d.ts +7 -0
  192. package/dist/vite/utils/index.js +23 -0
  193. package/dist/vite/utils/plugin.d.ts +11 -0
  194. package/dist/vite/utils/plugin.js +45 -0
  195. package/dist/vite/utils/url.d.ts +28 -0
  196. package/dist/vite/utils/url.js +69 -0
  197. package/dist/vite/utils/utils.d.ts +3 -0
  198. package/dist/vite/utils/utils.js +14 -0
  199. package/dist/vue/babel.d.ts +3 -0
  200. package/dist/vue/babel.js +17 -0
  201. package/dist/vue/index.d.ts +4 -0
  202. package/dist/vue/index.js +19 -0
  203. package/dist/vue/transforms/index.d.ts +13 -0
  204. package/dist/vue/transforms/index.js +48 -0
  205. package/dist/vue/transforms/templateTransformAssetUrl.d.ts +33 -0
  206. package/dist/vue/transforms/templateTransformAssetUrl.js +150 -0
  207. package/dist/vue/transforms/templateTransformSrcset.d.ts +4 -0
  208. package/dist/vue/transforms/templateTransformSrcset.js +122 -0
  209. package/dist/vue/transforms/templateUtils.d.ts +9 -0
  210. package/dist/vue/transforms/templateUtils.js +41 -0
  211. package/dist/vue/transforms/transformComponent.d.ts +3 -0
  212. package/dist/vue/transforms/transformComponent.js +26 -0
  213. package/dist/vue/transforms/transformEvent.d.ts +2 -0
  214. package/dist/vue/transforms/transformEvent.js +28 -0
  215. package/dist/vue/transforms/transformPageHead.d.ts +2 -0
  216. package/dist/vue/transforms/transformPageHead.js +11 -0
  217. package/dist/vue/transforms/transformRef.d.ts +2 -0
  218. package/dist/vue/transforms/transformRef.js +32 -0
  219. package/dist/vue/transforms/transformTag.d.ts +2 -0
  220. package/dist/vue/transforms/transformTag.js +18 -0
  221. package/dist/vue/transforms/vModel.d.ts +12 -0
  222. package/dist/vue/transforms/vModel.js +33 -0
  223. package/dist/vue/transforms/vOn.d.ts +15 -0
  224. package/dist/vue/transforms/vOn.js +88 -0
  225. package/dist/vue/utils.d.ts +31 -0
  226. package/dist/vue/utils.js +120 -0
  227. package/dist/watcher.d.ts +30 -0
  228. package/dist/watcher.js +92 -0
  229. package/lib/crypto.js +65 -0
  230. package/lib/nvue.css +34 -0
  231. package/lib/preprocess/LICENSE +13 -0
  232. package/lib/preprocess/README.md +410 -0
  233. package/lib/preprocess/lib/preprocess.js +437 -0
  234. package/lib/preprocess/lib/regexrules.js +121 -0
  235. package/lib/preprocess/package.json +68 -0
  236. package/package.json +68 -0
@@ -0,0 +1,410 @@
1
+ # preprocess
2
+ [![NPM][npm-image]][npm-url]
3
+
4
+ [![Linux Build Status][linux-ci-image]][linux-ci-url] [![Windows Build Status][windows-ci-image]][windows-ci-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][deps-image]][deps-url] [![dev-dependencies][dev-deps-image]][dev-deps-url]
5
+
6
+ Preprocess HTML, JavaScript, and other files with directives based off custom or ENV configuration
7
+
8
+ ## Configuration
9
+
10
+ Install via npm:
11
+
12
+ ```bash
13
+ $ npm install --save preprocess
14
+ ```
15
+
16
+ ## What does it look like?
17
+
18
+ ```html
19
+ <head>
20
+ <title>Your App</title>
21
+
22
+ <!-- @if NODE_ENV='production' -->
23
+ <script src="some/production/lib/like/analytics.js"></script>
24
+ <!-- @endif -->
25
+
26
+ </head>
27
+ <body>
28
+ <!-- @ifdef DEBUG -->
29
+ <h1>Debugging mode - <!-- @echo RELEASE_TAG --> </h1>
30
+ <!-- @endif -->
31
+ <p>
32
+ <!-- @include welcome_message.txt -->
33
+ </p>
34
+ </body>
35
+ ```
36
+
37
+ ```js
38
+ var configValue = '/* @echo FOO */' || 'default value';
39
+
40
+ // @ifdef DEBUG
41
+ someDebuggingCall()
42
+ // @endif
43
+
44
+ ```
45
+
46
+ ## Directive syntax
47
+
48
+ ### Basic example
49
+
50
+ The most basic usage is for files that only have two states, non-processed and processed.
51
+ In this case, your `@exclude` directives are removed after preprocessing
52
+
53
+ ```html
54
+ <body>
55
+ <!-- @exclude -->
56
+ <header>You're on dev!</header>
57
+ <!-- @endexclude -->
58
+ </body>
59
+ ```
60
+
61
+ After build
62
+
63
+ ```html
64
+ <body>
65
+ </body>
66
+ ```
67
+
68
+ ### All directives
69
+
70
+ - `@if VAR='value'` / `@endif`
71
+ This will include the enclosed block if your test passes
72
+ - `@ifdef VAR` / `@endif`
73
+ This will include the enclosed block if VAR is defined (typeof !== 'undefined')
74
+ - `@ifndef VAR` / `@endif`
75
+ This will include the enclosed block if VAR is not defined (typeof === 'undefined')
76
+ - `@include`
77
+ This will include the source from an external file. If the included source ends with a newline then the
78
+ following line will be space indented to the level the @include was found.
79
+ - `@include-static`
80
+ Works the same way as `@include` but doesn't process the included file recursively. Is useful if a large
81
+ file has to be included and the recursive processing is not necessary or would otherwise take too long.
82
+ - `@extend file.html` / `@endextend`
83
+ This will use the source from the external file indicated with the `@extend` tag to wrap the enclosed block.
84
+ - `@extendable`
85
+ This tag is used to indicate the location in a file referenced using `@extend` where the block enclosed by `@extend` will be populated.
86
+ - `@exclude` / `@endexclude`
87
+ This will remove the enclosed block upon processing
88
+ - `@echo VAR`
89
+ This will include the environment variable VAR into your source
90
+ - `@foreach $VAR in ARR` / `@endfor`
91
+ This will repeat the enclosed block for each value in the Array or Object in ARR. Each value in ARR can be interpolated into the resulting content with $VAR.
92
+ - `@exec FUNCTION([param1, param2...])`
93
+ This will execute the environment FUNCTION with its parameters and echo the result into your source. The parameter
94
+ could be a string or a reference to another environment variable.
95
+
96
+ ### Extended html Syntax
97
+
98
+ This is useful for more fine grained control of your files over multiple
99
+ environment configurations. You have access to simple tests of any variable within the context (or ENV, if not supplied)
100
+
101
+ ```html
102
+ <body>
103
+ <!-- @if NODE_ENV!='production' -->
104
+ <header>You're on dev!</header>
105
+ <!-- @endif -->
106
+
107
+ <!-- @if NODE_ENV='production' -->
108
+ <script src="some/production/javascript.js"></script>
109
+ <!-- @endif -->
110
+
111
+ <script>
112
+ var fingerprint = '<!-- @echo COMMIT_HASH -->' || 'DEFAULT';
113
+ </script>
114
+
115
+ <script src="<!-- @exec static_path('another/production/javascript.js') -->"></script>
116
+ </body>
117
+ ```
118
+
119
+ With a `NODE_ENV` set to `production` and `0xDEADBEEF` in
120
+ `COMMIT_HASH` this will be built to look like
121
+
122
+ ```html
123
+ <body>
124
+ <script src="some/production/javascript.js"></script>
125
+
126
+ <script>
127
+ var fingerprint = '0xDEADBEEF' || 'DEFAULT';
128
+ </script>
129
+
130
+ <script src="http://cdn2.my.domain.com/another/javascript.js"></script>
131
+ </body>
132
+ ```
133
+
134
+ With NODE_ENV not set or set to dev and nothing in COMMIT_HASH,
135
+ the built file will be
136
+
137
+ ```html
138
+ <body>
139
+ <header>You're on dev!</header>
140
+
141
+ <script>
142
+ var fingerprint = '' || 'DEFAULT';
143
+ </script>
144
+
145
+ <script src="http://localhost/myapp/statics/another/javascript.js"></script>
146
+ </body>
147
+ ```
148
+
149
+ You can also have conditional blocks that are hidden by default by using the
150
+ fictional `!>` end tag instead of `-->` after your condition:
151
+
152
+ ```html
153
+ <!-- @if true !>
154
+ <p>Process was run!</p>
155
+ <!-- @endif -->
156
+ ```
157
+
158
+ ### JavaScript, CSS, C, Java Syntax
159
+
160
+ Extended syntax below, but will work without specifying a test
161
+
162
+ ```js
163
+ normalFunction();
164
+ //@exclude
165
+ superExpensiveDebugFunction()
166
+ //@endexclude
167
+
168
+ anotherFunction('/* @echo USERNAME */');
169
+ ```
170
+
171
+ Built with a NODE_ENV of production :
172
+
173
+ ```js
174
+ normalFunction();
175
+
176
+ anotherFunction('jsoverson');
177
+ ```
178
+
179
+ Like HTML, you can have conditional blocks that are hidden by default by ending the directive with a `**` instead of `*/`
180
+
181
+ ```js
182
+ angular.module('myModule', ['dep1'
183
+ , 'dep2'
184
+ /* @if NODE_ENV='production' **
185
+ , 'prod_dep'
186
+ /* @endif */
187
+ /* @exclude **
188
+ , 'debug_dep'
189
+ /* @endexclude */
190
+ ]);
191
+
192
+ ```
193
+
194
+ _Note: Hidden by default blocks only work with block comments (`/* */`) but not with line comments (`//`)._
195
+
196
+ CSS example
197
+
198
+ ```css
199
+ body {
200
+ /* @if NODE_ENV=='development' */
201
+ background-color: red;
202
+ /* @endif */
203
+
204
+ }
205
+ // @include util.css
206
+ ```
207
+
208
+ (CSS preprocessing supports single line comment style directives)
209
+
210
+
211
+
212
+ ### Shell, PHP
213
+
214
+ ```bash
215
+ #!/bin/bash
216
+
217
+ # @include util.sh
218
+ ```
219
+
220
+ ## API
221
+
222
+ ### preprocess(source[, context[, options]]) -> preprocessedSource
223
+
224
+ Preprocesses a source provided as a string and returns the preprocessed source.
225
+
226
+ #### source
227
+ Type: `String` (mandatory)
228
+
229
+ The source to preprocess.
230
+
231
+ #### context
232
+ Type: `Object`
233
+ Default: `process.env`
234
+
235
+ The context that contains the variables that are used in the source. For `@extend` variants and `@include` the additional
236
+ context property `src` is available inside of files to be included that contains the current file name. This property is also
237
+ available in the context of the source file if one of the `preprocessFile*()` API variants are used.
238
+
239
+ #### options
240
+ Type: `Object`
241
+
242
+ The options object allows to pass additional options to `preprocess`. Available options are:
243
+
244
+ ##### options.fileNotFoundSilentFail
245
+ Type: `Boolean`
246
+ Default: `false`
247
+
248
+ When using `@include` variants and `@extend`, `preprocess` will by default throw an exception in case an included
249
+ file can't be found. Set this option to `true` to instruct `preprocess` to fail silently and instead of throwing
250
+ to write a message inside of the preprocessed file that an included file could not be found.
251
+
252
+ ##### options.srcDir
253
+ Type: `String`
254
+ Default: `process.cwd()`
255
+
256
+ The directory where to look for files included via `@include` variants and `@extend`.
257
+
258
+ ##### options.srcEol
259
+ Type: `String`
260
+ Default: EOL of source string or `os.EOL` if source string contains multiple different or no EOLs.
261
+
262
+ The end of line (EOL) character to use for the preprocessed result. May be one of:
263
+ - `\r\n` - Windows
264
+ - `\n` - Linux/OSX/Unix
265
+ - `\r` - legacy Mac
266
+
267
+ ##### options.type
268
+ Type: `String`
269
+ Default: `html`
270
+
271
+ The syntax type of source string to preprocess. There are 3 main syntax variants:
272
+ - `html`, aliases: `xml`
273
+ - `js`, aliases: `javascript`, `jsx`, `c`, `cc`, `cpp`, `cs`, `csharp`, `java`, `less`, `sass`, `scss`, `css`, `php`,
274
+ `ts`, `tsx`, `peg`, `pegjs`, `jade`, `styl`
275
+ - `coffee`, aliases: `bash`, `shell`, `sh`
276
+
277
+ ### preprocessFile(srcFile, destFile[, context[, callback[, options]]])
278
+
279
+ Preprocesses a `sourceFile` and saves the result to `destFile`. Simple wrapper around `fs.readFile()` and `fs.writeFile()`.
280
+
281
+ #### srcFile
282
+ Type: `String` (mandatory)
283
+
284
+ The path to the source file to preprocess.
285
+
286
+ #### destFile
287
+ Type: `String` (mandatory)
288
+
289
+ The path to the destination file where the preprocessed result shall be saved.
290
+
291
+ #### context
292
+ See `context` [attribute description](#context) of `preprocess()` function.
293
+
294
+ #### callback
295
+ Type: `function(err)`
296
+
297
+ The callback function that is called upon error or completion. Receives an error if something goes wrong as first parameter.
298
+
299
+ #### options
300
+ See `options` [attribute description](#options) of `preprocess()` function. Differs only in that the default `srcDir` value is set
301
+ to the path of the provided source file instead of `process.cwd()` and the default `type` is derived from source file extension.
302
+
303
+
304
+ ### preprocessFileSync(srcFile, destFile[, context[, options]])
305
+
306
+ Preprocesses a `sourceFile` and saves the result to `destFile`. Simple wrapper around `fs.readFileSync()` and `fs.writeFileSync()`.
307
+
308
+ #### srcFile
309
+ Type: `String` (mandatory)
310
+
311
+ The path to the source file to preprocess.
312
+
313
+ #### destFile
314
+ Type: `String` (mandatory)
315
+
316
+ The path to the destination file where the preprocessed result shall be saved.
317
+
318
+ #### context
319
+ See `context` [attribute description](#context) of `preprocess()` function.
320
+
321
+ #### options
322
+ See `options` [attribute description](#options) of `preprocess()` function. Differs only in that the default `srcDir` value is set
323
+ to the path of the provided source file instead of `process.cwd()` and the default `type` is derived from source file extension.
324
+
325
+ ## Usage Examples
326
+
327
+ ```js
328
+ var pp = require('preprocess');
329
+
330
+ var text = 'Hi, I am <!-- @echo USERNAME -->';
331
+
332
+ pp.preprocess(text);
333
+ // -> Hi, I am jsoverson
334
+
335
+ pp.preprocess(text, {USERNAME : "Bob"});
336
+ // -> Hi, I am Bob
337
+
338
+ // specify the format to use for the directives as the third parameter
339
+ pp.preprocess(text, {USERNAME : "Bob"}, {type: 'html'});
340
+ // -> Hi, I am Bob
341
+
342
+ // Preprocess files asynchronously
343
+ pp.preprocessFile(src, dest, context, callback, options);
344
+
345
+ // Preprocess files synchronously
346
+ pp.preprocessFileSync(src, dest, context, options);
347
+ ```
348
+
349
+ ## Contributing
350
+ In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or
351
+ changed functionality. Lint and test your code using jshint
352
+
353
+ ## Release History
354
+ - 3.1.0
355
+ - Added `.jsx` file extension as an alias for `js` (@BendingBender, #79)
356
+ - Added `.tsx` file extension as an alias for `js` (@rosendi, #100)
357
+ - Bumped XRegExp to v3
358
+
359
+ - 3.0.1/2 Fixes for backward compatibility and regex cleanups (thanks to @anseki for suggestions, #77)
360
+ - 3.0.0
361
+
362
+ Breaking changes:
363
+ - If a file requested by `@include` or `@extend` can not be found, `preprocess` will now throw by default
364
+ with a possibility to opt in to the legacy behavior via the `fileNotFoundSilentFail` option (@BendingBender, #35).
365
+ - Fixed multiple issues with newlines (@BendingBender, #8), this may result in output that differs from earlier
366
+ versions.
367
+ - The `srcDir` option was moved to the options object and now defaults to `process.cwd` instead of throwing by
368
+ default (@BendingBender, #68)
369
+
370
+ New functionality:
371
+ - All block directives (ones that have a start and an end token, like `@if`/`@endif`) are now processed recursively (@Frizi, #61)
372
+ - Added hidden by default configuration blocks for `js` (@mallowigi, #40) and `html` (@Frizi, #66)
373
+
374
+ Fixes:
375
+ - fixed `@exec` in files included via `@include` and `@extend` (@BendingBender, #58)
376
+ - changed `@extend` and `@exclude` html regex so that directives may appear more than once in one line (@BendingBender, #36)
377
+ - fixed multiple issues with coffescript syntax (@BendingBender, #39)
378
+ - fixed `@if` and `@foreach` to not require trailing whitespace (@BendingBender, #74)
379
+
380
+ - 2.3.1 Fixed @echo and @exec directives to allow `-` and `*` characters, fixed @exec with multiple params (@BendingBender, #21, #45, #51, #54).
381
+ - 2.3.0 Added support for @include-static (@BendingBender)
382
+ - 2.2.0 Added support for @foreach and @extend (@orionstein)
383
+ - 2.1.1 Added support for .styl files via js regex (@nsonnad)
384
+ - 2.1.0 Added automatic support for numerous formats, merged @exec, hidden by default html tags, added simple directives
385
+ - 2.0.0 Added ability to echo strings, added conditional comments, removed lodash, merged 17, 13, 15, 16
386
+ - 1.2.0 Added processing for hash-style comments (@marsch). Added more file aliases.
387
+ - 1.1.0 Added deep inclusion, fixed sequential ifs
388
+ - 1.0.1 Fixed multiple inline echo statements
389
+ - 1.0.0 Pulled from grunt-preprocess to stand alone
390
+
391
+ ## License
392
+
393
+ Copyright Jarrod Overson
394
+
395
+ Written by Jarrod Overson
396
+
397
+ Licensed under the Apache 2.0 license.
398
+
399
+ [npm-image]: https://nodei.co/npm/preprocess.png?downloads=true
400
+ [npm-url]: https://www.npmjs.com/package/preprocess
401
+ [linux-ci-image]: https://img.shields.io/travis/jsoverson/preprocess/master.svg?style=flat-square&label=Linux%20build
402
+ [linux-ci-url]: https://travis-ci.org/jsoverson/preprocess
403
+ [windows-ci-image]: https://img.shields.io/appveyor/ci/BendingBender/preprocess/master.svg?style=flat-square&label=Windows%20build
404
+ [windows-ci-url]: https://ci.appveyor.com/project/BendingBender/preprocess
405
+ [deps-image]: https://img.shields.io/david/jsoverson/preprocess.svg?style=flat-square
406
+ [deps-url]: https://david-dm.org/jsoverson/preprocess
407
+ [dev-deps-image]: https://img.shields.io/david/dev/jsoverson/preprocess.svg?style=flat-square
408
+ [dev-deps-url]: https://david-dm.org/jsoverson/preprocess#info=devDependencies
409
+ [coverage-image]: https://img.shields.io/coveralls/jsoverson/preprocess/master.svg?style=flat-square
410
+ [coverage-url]: https://coveralls.io/r/jsoverson/preprocess?branch=master