S
S
Stanislav2018-02-24 10:12:22
webpack
Stanislav, 2018-02-24 10:12:22

How to leave only your code in webpack?

Webpack adds extra code during assembly (the file with the code is empty), I get the output

!function(n){function t(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return n[e].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};t.m=n,t.c=r,t.d=function(n,r,e){t.o(n,r)||Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:e})},t.n=function(n){var r=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(r,"a",r),r},t.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},t.p="",t(t.s=1)}([,function(n,t,r){r(2),n.exports=r(3)},function(n,t){},function(n,t){}]);

Here is the config
'use strict';

const path = require('path')
const webpack = require('webpack')

module.exports = {
    context: path.join(__dirname, './static/'),
    entry: {
        'utils.min.js': './ajax/utils.js',
        'async.min.js': [
            './ajax/async.js',
            './ajax/async2.js'
        ]
    },
    output: {
        path: path.join(__dirname, './static/assets'),
        filename: "[name]"
    },
    plugins: [
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false,
                drop_console: true,
                unsafe: true
            }
        })
    ]
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2018-02-24
@ms-dred

No way, all bundlers have an overhead.
Previously, the webpack site had a sign stating that it had the smallest overhead.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question