Code Monkey home page Code Monkey logo

extjs-webpack's Introduction

Ext JS webpack App

A simple demonstration of using webpack to build an app bundle to go along with the pre-built Ext JS library.

The goal here is to use fully modern build tools, avoiding Sencha Cmd, so that we get import, export and sourcemaps.

Getting Started

Make an ext folder that links to your Ext JS download content. In the checkout directory, run a command like this:

$ ln -s ../../sdks/ext-6.5.3 ext

On Windows:

> mklink /D ext ..\..\sdks\ext-6.5.3

As alternative, in case you need a custom ExtJS build (like upgrading FontAwesome to Pro), in the ExtJS release directory ext-6.5.3/ run sench package build to build ExtJS files. Then after build, you can copy in project/ext/build the ext-6.5.3/build/modern, ext-6.5.3/build/packages, and ext-6.5.3/build/ext-modern-all.js, -debug.js. files into your project.

Then run yarn run build:

$ yarn run build

> [email protected] build ..../extjs-webpack
> webpack

Hash: 514ce3b213ceda0e6dbe
Version: webpack 4.42.1
Time: 99ms
Built at: 04/05/2020 6:17:04 PM
    Asset      Size  Chunks             Chunk Names
bundle.js  4.98 KiB    main  [emitted]  main
Entrypoint main = bundle.js
[./src/app.js] 300 bytes {main} [built]
[./src/view/Main.js] 245 bytes {main} [built]

That's all. Now load in browser.

Going Forward

First thing to note is that all app files are modules and you import them. They can export their constructors like I did in Main.js:

export default
Ext.define('App.view.Main, {
    ...
});

The Ext.define() function needs to be used to extend Ext JS classes and it returns the class constructor. We export it so that other modules can get it in an ES6 way as I do in app.js:

import Main from './view/Main.js'

The class is still placed on the global scope as App.view.Main, but following the ES6 way will clarify relationships for the bundler.

Strict Mode

Modules use strict mode, so be aware that callParent cannot be called from a function declared in such places. This is easy to work around as I do in Main:

const Panel = Ext.Panel;
const superCls = Panel.prototype;

export default
Ext.define('App.view.Main', {
    extend: Panel,

    title : 'App',

    constructor(...args) {
        superCls.constructor.call(this, ...args);
    }
});

Normally, in Ext JS, the constructor override would have used callParent to call the Panel super class.

Conclusion

Using Sencha Themer would be great partner here. Just build your theme and link it in via the index file.

I'd love to hear what folks think of this approach!

extjs-webpack's People

Contributors

dependabot[bot] avatar vadimpopa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

geovannyjs dawesi

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.