Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
grunt-requirejs-auto-bundles
Advanced tools
Automated shared bundles for grunt-contrib-requirejs builds.
Automated shared bundles for grunt-contrib-requirejs.
This task automatically updates and optimizes your modules:
config for
RequireJS optimizer builds.
This means you can create projects that have multiple "main" or "entry" modules, but also easily have all common modules placed into bundles to reduce total download for your users.
This leaves you the freedom to focus on setting your module dependencies accurately, instead of optimally for your builds.
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-requirejs-auto-bundles --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-requirejs-auto-bundles');
This task reads your requirejs.config()
and your grunt-contrib-requirejs
build config, figures out the contents of the shared bundles, then updates your
modules:
config for your requirejs
task (it won't produce the final build).
Therefore, it is advised to begin with grunt-contrib-requirejs
and get that
working with the dir:
and modules:
options for its requirejs
task.
Then, in your project's Gruntfile, add a section named autobundles
to the
data object passed into grunt.initConfig()
.
grunt.initConfig({
autobundles: {
your_target: {
requireConfigModule: 'require-config'
},
},
requirejs: {
your_target: {
// Your `requirejs` config goes here, at a minimum you must have:
appDir: 'path/to/app',
baseUrl: './',
dir: 'path/to/build',
modules: [
{ name: 'require-config' },
{ name: 'main-a' },
{ name: 'main-b' }
]
}
}
});
Then, you should configure your build task to first run autobundles
before
requirejs
:
grunt.registerTask('build', ['autobundles', 'requirejs']);
Type: String
Default value: 'require-config'
The module ID for the JS file that calls requirejs.config({ ... })
.
In addition to the example task configuration above, you're expected to setup your project like so:
Contents of require-config.js
:
requirejs.config({
// Your RequireJS loader config goes here.
});
In your HTML, you'll need to load your require-config.js
first, then your
"main" module.
When in development, you'll want to do something like this:
<script src="/src/require.js"></script>
<script>
require.config({
baseUrl: '/src'
});
require(['require-config'], function() {
require(['main-a']);
});
</script>
When in production, you'll want to change the paths to point to the build dir
as specified by the dir:
setting for requirejs
:
<script src="/build/require.js"></script>
<script>
require.config({
baseUrl: '/build'
});
require(['require-config'], function() {
require(['main-a']);
});
</script>
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.
(Nothing yet)
FAQs
Automated shared bundles for grunt-contrib-requirejs builds.
The npm package grunt-requirejs-auto-bundles receives a total of 4 weekly downloads. As such, grunt-requirejs-auto-bundles popularity was classified as not popular.
We found that grunt-requirejs-auto-bundles demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.