Webpack - '速度未定义'

问题描述 投票:1回答:1

我正在使用webpack和gulp,这是我的webpack配置:

webpack.config.js

const path = require('path');
var HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
module.exports = {
    output: {
        publicPath: "./dist/",
        path: path.join(__dirname, "/js/"),
        filename: "bundle.js"
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: "babel-loader",
                query: {
                    presets: ["env"]
                }
            },
            {
                test: /\.vue$/,
                loader: 'vue-loader'
            }
        ]
    },
    resolve: {
        alias: {
            moment: 'moment/src/moment'
        }
    },
    externals: {
        jquery: 'jQuery',
        $: 'jQuery',
        moment: 'moment',
        "velocity-animate": 'velocity'
    },
    plugins: [
        new HardSourceWebpackPlugin()
    ]
};

scripts.js(这就是这个文件中的所有内容)

import velocity from 'velocity-animate';

我得到了这个错误

Uncaught ReferenceError: velocity is not defined

这行错误:

module.exports = velocity;

我在外部配置上做错了吗?这适用于moment.js和jQuery,但不适用于速度......

我试过了

"velocity-animate": 'velocity'

"velocity-animate": 'velocity-animate'

"velocity-animate": '"velocity-animate"'

这些都不起作用。如果第一个不是'velocity-animate'(包的名称),那么无论如何Velocity.js都包含在脚本中。关于此的文档并没有真正解释如何正确配置它

这个用例是否真的可能是如此利基,以至于没有人能解释它?

谢谢!

javascript webpack velocity.js
1个回答
2
投票

这里是Velocity V2的领导开发者。

Doh - 我们错过了更新Velocity的出口 - 我会在今天晚些时候得到它。我们也正在进行模块化过程,因此您可以在Webpack项目中“正常”导入它(包括树摇动等) - 这应该在下周左右完成。

直到我推出一个更新的版本,它输出的名称是"Velocity" - 注意大写“V” - 希望今天晚些时候它会移动(2.0.2 @beta将有更正的名称"velocity-animate")。

© www.soinside.com 2019 - 2024. All rights reserved.