Coder Social home page Coder Social logo

webpack-build's Introduction

AAXISWebpackBundle

AAXISWebpackBundle supports Webpack build.

Commands

aaxis:webpack:dump command

Generates dynamic info of webpack.config. The output file is <ProjectDir>/webpack.app.config.json

aaxis:webpack:build command

Execute webpack. Requires <ProjectDir>/package.json and <ProjectDir>/webpack.app.config.js. Examples when use AAXISReatBundle.

package.json

{
  "name": "aaxis-build",
  "description": "Build static resources",
  "license": "MIT",
  "main": "webpack.config.js",
  "devDependencies": {
    "path": "^0.12.7",
    "webpack": "^4.17.2",
    "webpack-cli": "^3.1.0",
    "webpack-merge": "^4.1.2",
    "@babel/core": "^7.6.4",
    "@babel/preset-env": "^7.6.3",
    "@babel/preset-react": "^7.6.3",
    "babel-loader": "^8.0.6",
    "react": "^16.10.2",
    "react-dom": "^16.10.2",
    "axios": "^0.18.0",
    "dva": "^2.2.3",
    "dva-loading": "^2.0.1"
  },
  "dependencies": {
    "@babel/plugin-proposal-class-properties": "^7.5.5",
    "@babel/plugin-proposal-decorators": "^7.6.0",
    "@babel/plugin-transform-runtime": "^7.6.2",
    "@babel/preset-stage-2": "^7.0.0",
    "underscore": "^1.9.1"
  }
}

webpack.app.config.js

const config = require('./webpack.app.config.json');
const webpackMerge = require('webpack-merge');

module.exports = webpackMerge(config, {
    output: {
        filename: '[name].bundle.js',
        libraryTarget: 'amd'
    },
    externals: {
        react: {
            amd: 'react'
        },
        underscore: {
            amd: 'underscore'
        },
        'react-utils': {
            amd: 'react-utils'
        }
    },
    module: {
        rules: [{
            test: /\.jsx$/,
            loader: 'babel-loader',
            options: {
                presets: [
                    "@babel/preset-env", "@babel/preset-react"
                ]
            }
        }]
    },
    resolve: {
        alias: {
            'react-utils': './public/bundles/aaxisreact/js/common/dummy-object'
        }
    }
});

Command listener

The bundle listens to event console.comman. Command aaxis:webpack:build will be triggered before oro:assets:build Command aaxis:webpack:dump will be triggered before aaxis:webpack:build

Entry Config

Entries are configured in file <BundleName>/Resources/views/layouts/<ThemeName>/config/entry-points.yml Theme folder path will be prepended to entry names automatically to make sure the file will be generated to the theme folder.

There are files

countries.jsx
orders.jsx

Under folder AAXIS/Bundle/AppBundle/Resources/public/blank/js/react/components Content of file AAXIS/Bundle/AppBundle/Resources/views/layouts/blank/config/entry-points.yml

entry:
    js/react/components/countries: js/react/components/countries.jsx
    js/react/components/orders: js/react/components/orders.jsx

Execute command aaxis:webpack:build, files are generated to folder AAXIS/Bundle/AppBundle/Resources/public/blank/js/react/components

countries.bundle.js
orders.bundle.js

Instead of configure them one by one, you can use wildcard. The output is same:

entry:
    js/react/components/*.jsx: ~

The entry configuration also supports array:

entry:
    all: [js/react/components/orders.jsx,js/react/components/countries.jsx]

The output file is AAXIS/Bundle/AppBundle/Resources/public/blank/all.bundle.js

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.