Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
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: Object
Default: {NODE_ENV: 'development'}
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: Boolean
Default: undefined
Required to enable overwriting of source files
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
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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.