Socket
Socket
Sign inDemoInstall

grunt-import-js

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-import-js


Version published
Weekly downloads
174
decreased by-47.27%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

grunt-import-js

Import JS files within JS files by @import instruction.

Getting Started

This plugin requires Grunt ~0.4.0

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-import-js --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-import-js');

The "import_js" task

Add @import instructions to your JS files and let them be replaced by the content of the files.

@import "vendor/js/jquery/jquery.min.js"; 
@import "vendor/js/bootstrap/bootstrap.min.js"; 
@import "base.js"; 

Optionally, you can comment out the instructions to keep your files executable without this plugin. This is also useful when using syntax checker (e.g. jshint), since "@import" is not a valid JS-statement.

// @import "vendor/js/jquery/jquery.min.js"; 
// @import "vendor/js/bootstrap/bootstrap.min.js"; 
// @import "base.js"; 

Overview

In your project's Gruntfile, add a section named import_js to the data object passed into grunt.initConfig(). Usage Example below.

Options

importDir

Type: String
Default: files.cwd

Specifies an alternate location for the @import files.

Usage Examples

In this example, import-js is used to read all javascript files from app/Resources/js/ and scan them for @import instructions. The content of the @import files then replaces the @import instruction.

grunt.initConfig({
  import_js: {
    files: {
      expand: true,
      cwd: 'app/Resources/js/',
      src: ['**/*.js'],
      dest: 'assets/js/',
      ext: '.js'
    }
  },
});

Release History

  • 2016-01-21   v0.1.4   file not found message changed from "fail.fatal" to "log.error"
  • 2015-11-13   v0.1.3   fixed regex bug
  • 2015-10-01   v0.1.2   readme updated
  • 2015-09-30   v0.1.1   instructions are now optional, readme updated
  • 2015-09-03   v0.1.0   

Keywords

FAQs

Last updated on 21 Jan 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc