Code Monkey home page Code Monkey logo

kendo-ui-webpack's Introduction

Kendo UI Core for Webpack / CommonJS

This is a proxy module for kendo-ui-core, referencing directly the raw source code (not minified) with all components and classes accessible via require() calls.

Don't bother where to find a specific class. Don't list the components you really need in your Gruntfile (or whatever). Let Webpack do the work for you.

It will find automagically all dependencies and happily minify your code, resulting in a compact build.

Advantages

  • smaller code base, because only really used widgets are included
  • automatic dependency injection - you don't have to manually list the used Kendo files in your build
  • Webpack friendly - only required static assets (images etc.) are included and can be inlined, just the way you want it
  • minify / uglify the way you want it

Usage

You can still use Kendo components either as jQuery plugins or via markdown. In either case you have to require() the components you use.

A module of your application might look like this:

var kendoCalendar = require("kendo-ui-webpack/kendo.ui.Calendar");
var cal = new kendoCalendar($("#my-calendar"));

or, as a plugin:

require("kendo-ui-webpack/kendo.ui.Calendar");
$("#my-calendar").kendoCalendar();

Module names

All classes can be require()d by their name in global namespace. As in the example above, the kendo.ui.Calendar class (which Kendo also injects into the global namespace) can be loaded via require("kendo-ui-webpack/kendo.ui.Calendar").

If you want shorter names in the require() call, you might use Webpacks module alias feature.

For example, having a Webpack config like...

  resolve: {
    alias : {
      "kendo": "kendo-ui-webpack"
    }
  },

allows a simpler/shorter require("kendo/kendo.ui.Calendar")

Installing

Dependencies

First, you need to add the required modules:

npm install kendo-ui-webpack --save
npm install jquery --save
npm install imports-loader --save

The imports-loader is a mandatory Webpack loader that helps with a nasty Kendo problem. The core library depends on jQuery, but doesn't tell so in the CommonJS requires. The imports-loaded helps to add the dependency and to inject the "global variable" jQuery, that's expected by Kendo.

For the loader to work, you need to add the following configuration to the Webpack config:

  module: {
    loaders: {
      { test: /kendo\-ui\-core[\///].*\.js$/, loader: "imports?jQuery=jquery" },
    }
  }

Unfortunately, there is no way to automatize this in kendo-ui-webpack itself.

Add CSS theme

Furthermore, you might want add the CSS styles of the Kendo theme you choose to use. In the most basic form that means you add the following code at some central place (probably the entry point) of your application:

require("kendo/styles/web/kendo.common.core.css");
require("kendo/styles/web/kendo.default.css");

Or, if you didn't define the alias (see above)...

require("kendo-ui-webpack/styles/web/kendo.common.core.css");
require("kendo-ui-webpack/styles/web/kendo.default.css");

How this works

This package mainly consists of a "generator" script that has a internal list describing all public Kendo classes and the corresponding file that defines it. At NPM install time, it generates a bunch of tiny .js files that make up the modules you can require() and themselves require() the correct Kendo file.

This basically looks like this (kendo.ui.Button.js):

module.exports = require("kendo-ui-core/src/kendo.button.js").ui.Button;

This allows the Webpack analyzer to find the relevant files and once minimized this shouldn't take up much space (much less than including the complete Kendo source code) nor have a relevant influence to the runtime speed of your application.

kendo-ui-webpack's People

Contributors

amarant avatar jampy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.