Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
grunt-preprocess
Advanced tools
Preprocess HTML and JavaScript directives based off environment configuration
Grunt task around preprocess npm module
<head>
<title>Your App</title>
<!-- @if NODE_ENV='production' -->
<script src="some/production/lib/like/analytics.js"></script>
<!-- @endif -->
</head>
<body>
<!-- @ifdef DEBUG -->
<h1>Debugging mode - <!-- @echo RELEASE_TAG --> </h1>
<!-- @endif -->
<p>
<!-- @include welcome_message.txt -->
</p>
</body>
var configValue = '/* @echo FOO */' || 'default value';
// @ifdef DEBUG
someDebuggingCall()
// @endif
See preprocess documentation for more information
Install this grunt plugin next to your project's Gruntfile with: npm install --save-dev grunt-preprocess
Then add this line to your project's Gruntfile:
grunt.loadNpmTasks('grunt-preprocess');
Type: Boolean
Default: undefined
Required to enable overwriting of source files
Type: Object
Default: {}
The additional context on top of ENV that should be passed to templates. If NODE_ENV is not set, the task sets it to development
by default.
Type: String
Default: <path to source file to be processed>
The directory where to look for files included via @include
variants and @extend
.
Type: String
Default: EOL of source file or os.EOL
if source file contains multiple different or no EOLs.
The end of line (EOL) character to use for the preprocessed result. May be one of:
\r\n
- Windows\n
- Linux/OSX/Unix\r
- legacy MacType: String
Default: file extension of the file to be processed
The syntax type of source file to preprocess. See preprocess() description for a list of all supported file types.
preprocess : {
options: {
context : {
DEBUG: true
}
},
html : {
src : 'test/test.html',
dest : 'test/test.processed.html'
},
js : {
src : 'test/test.js',
dest : 'test/test.processed.js'
},
multifile : {
files : {
'test/test.processed.html' : 'test/test.html',
'test/test.processed.js' : 'test/test.js'
}
},
inline : {
src : [ 'processed/**/*.js' ],
options: {
inline : true,
context : {
DEBUG: false
}
}
},
all_from_dir: {
src: '**/*.tmpl',
ext: '.html',
cwd: 'src',
dest: 'build',
expand: true
}
}
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
context
optionWritten by Jarrod Overson
Licensed under the Apache 2.0 license.
FAQs
Preprocess HTML and JavaScript directives based off environment configuration
The npm package grunt-preprocess receives a total of 7,056 weekly downloads. As such, grunt-preprocess popularity was classified as popular.
We found that grunt-preprocess demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.