Skip to content

Even more modular #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lionel-bijaoui opened this issue Sep 12, 2016 · 6 comments
Closed

Even more modular #67

lionel-bijaoui opened this issue Sep 12, 2016 · 6 comments
Assignees
Milestone

Comments

@lionel-bijaoui
Copy link
Member

A very modularized version of the app would be a plus.
My goal is:

  • a simple, all in one (except for CSS of course) bundled JS.
    The user only need to include the lib with a script tag and it work as expected (like today build).
  • a commonjs version with dependency and the possibility to load individual fields or not (some fields have dependency that other don't so it could save some space in the end).
    This is close to Vue.js approach of the problem (vue.js vs vue.common.js)
@lionel-bijaoui lionel-bijaoui mentioned this issue Sep 12, 2016
2 tasks
@lionel-bijaoui
Copy link
Member Author

Progress update: removing moment and lodash from bundle is working. Size drop from 1.2M to 308.4k for node_modules chunk.

@icebob
Copy link
Member

icebob commented Sep 15, 2016

Nice!

@icebob
Copy link
Member

icebob commented Sep 22, 2016

Could you show the webpack config?

@lionel-bijaoui lionel-bijaoui added this to the v1.0 milestone Sep 22, 2016
@lionel-bijaoui
Copy link
Member Author

The only real change is here

        externals: {
            "lodash": "lodash",
            "moment": "moment"
        },

Config so far

var webpack = require("webpack");
var version = require("./package.json").version;
var banner = "/**\n" + " * vue-form-generator v" + version + "\n" + " * https://github.com/icebob/vue-form-generator\n" + " * Released under the MIT License.\n" + " */\n";
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var StatsPlugin = require("stats-webpack-plugin");

var loaders = [
    {
        "test": /\.js?$/,
        "exclude": /node_modules/,
        "loader": "babel"
    },
    {
        "test": /\.vue?$/,
        "loader": "vue"
    }
];

module.exports = [
    {
        entry: "./src/index",
        output: {
            path: "./dist",
            filename: "vue-form-generator.js",
            library: "VueFormGenerator",
            libraryTarget: "umd"
        },
        externals: {
            "lodash": "lodash",
            "moment": "moment"
        },

        plugins: [
            new webpack.DefinePlugin({
                "process.env" : {
                    NODE_ENV : JSON.stringify("production")
                }
            }),
            new webpack.optimize.UglifyJsPlugin({
                compress: {
                    warnings: false
                }
            }),
            new webpack.optimize.DedupePlugin(),
            new webpack.BannerPlugin(banner, {
                raw: true
            }),
            new ExtractTextPlugin("vue-form-generator.css", { allChunks: true }),
            new StatsPlugin("../stats.json", {
                chunkModules: true
                //exclude: [/node_modules[\\\/]react/]
            })
        ],

        module: {
            loaders: loaders
        },

        vue: {
            loaders: {
                css: ExtractTextPlugin.extract("css"),
                postcss: ExtractTextPlugin.extract("css"),
                sass: ExtractTextPlugin.extract("css!sass"),
            }
        },

        resolve: {
            packageAlias: "browser"
        }
    }

];

@icebob
Copy link
Member

icebob commented Sep 26, 2016

@lionel-bijaoui lionel-bijaoui self-assigned this Sep 27, 2016
@lionel-bijaoui lionel-bijaoui modified the milestones: v1.0.0, v2.0.0 Feb 13, 2017
@icebob
Copy link
Member

icebob commented Feb 15, 2017

I closed it. More discussion in #112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants