Skip to content

Incorrect work uglify with webpack #1727

Closed

Description

@arshtepe

After minimalization by uglify quotation marks were removed from string
config:

 var webpack = require("webpack");

 module.exports = {
    output: {
        filename:  "dist/index.js"
    },
    context: __dirname,
    entry: "./index.js",
    module: {
        loaders: [
            { test: /\.html/, loaders: ["html-loader"] },
        ]
    },
    plugins: [ new webpack.optimize.UglifyJsPlugin({ }) ]
}

index.js:

console.log( "text: "+ require("./index.html") );

index.html:

<span class="quick-search-shortcut" >
    <i class="icon-loupe" ></i>
</span>

result:

! function (o) {
    function r(e) {
        if (t[e]) return t[e].exports;
        var n = t[e] = {
            exports: {},
            id: e,
            loaded: !1
        };
        return o[e].call(n.exports, n, n.exports, r), n.loaded = !0, n.exports
    }
    var t = {};
    return r.m = o, r.c = t, r.p = "", r(0)
}([function (o, r, t) {
    var e = t(1);
    console.log("text: " + e)
}, function (o, r) {
    o.exports = "<span class=quick-search-shortcut><i class=icon-loupe></i></span>"//removed quotation marks in class attribute
}]);

Activity

  1. sokra commented on Dec 14, 2015

    @sokra
    Member

    That's working as intented. The quotes are optional. Minimizing removes them.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions