Tag:iviewvue.jswebpack
Article From:https://segmentfault.com/q/1010000012146974
Question:

Useiview-adminThe template set up the backstage system.

staydevIn the model everything is normal.

When executingnpm run buildThe following error occurred.

ERROR in main.e53c38756696d4c01357.js from UglifyJs
Unexpected token: operator (>) [main.e53c38756696d4c01357.js:3795,84]

Then go to the specific location to view the code as follows:

__WEBPACK_IMPORTED_MODULE_0__notification_vue___default.a.newInstance = properties => {
    const _props = properties || {};

    const Instance = new __WEBPACK_IMPORTED_MODULE_1_vue__["default"]({
        data: _props,
        render (h) {
            return h(__WEBPACK_IMPORTED_MODULE_0__notification_vue___default.a, {
                props: _props
            });
        }
    });

    const component = Instance.$mount();
    document.body.appendChild(component.$el);
    const notification = Instance.$children[0];

    return {
        notice (noticeProps) {
            notification.add(noticeProps);
        },
        remove (name) {
            notification.close(name);
        },
        component: notification,
        destroy (element) {
            notification.closeAll();
            setTimeout(function() {
                document.body.removeChild(document.getElementsByClassName(element)[0]);
            }, 500);
        }
    };
};

The first line is the wrong place, it should be=>It’s wrong. This is the ES6 grammar, and then we go to see it.iviewThe source of the source code:

import Notification from './notification.vue';
import Vue from 'vue';

Notification.newInstance = properties => {
    const _props = properties || {};

    const Instance = new Vue({
        data: _props,
        render (h) {
            return h(Notification, {
                props: _props
            });
        }
    });

    const component = Instance.$mount();
    document.body.appendChild(component.$el);
    const notification = Instance.$children[0];

    return {
        notice (noticeProps) {
            notification.add(noticeProps);
        },
        remove (name) {
            notification.close(name);
        },
        component: notification,
        destroy (element) {
            notification.closeAll();
            setTimeout(function() {
                document.body.removeChild(document.getElementsByClassName(element)[0]);
            }, 500);
        }
    };
};

export default Notification;

I looked at other files, including the other parts of the wrong file, which had been converted from ES6 to ES5, and there was no change in this place. It was strange, not knowing what was the reason.

Enclosed.babelrcTo configure:

{
    "presets": ["es2015", "stage-3"],
    "plugins": ["transform-runtime", "transform-vue-jsx"],
    "comments": true
}

webpack.base.config.jsTo configure:

{
    test: /iview\/.*?js$/,
    loader: 'babel-loader'
},
{
    test: /\.js$/,
    loader: 'babel-loader',
    exclude: /node_modules/
},
{
    test: /\.js[x]?$/,
    include: [resolve('src')],
    exclude: /node_modules/,
    loader: 'happypack/loader?id=happybabel'
}

It’s all used.iview-adminAwebpackConfiguration, have you ever met this situation?

I have been puzzled for several days by asking God to tell you and thank you.

Answer 0:

Download the latest version of iview-admin and try not to encounter this problem. Upgrade it.

Answer 1:

Obviously, when you compress the code, you can’t find hash key.

Leave a Reply

Your email address will not be published. Required fields are marked *