首页 文章

Webpack - 'velocity is not defined'

提问于
浏览
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

Error on this line:

module.exports = velocity;

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

我试过了

"velocity-animate": 'velocity'

"velocity-animate": 'velocity-animate'

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

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

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

谢谢!

1 回答

  • 2

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

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

    直到我推送一个更新的版本它的导出名称是 "Velocity" - 注意资本"V" - 希望今天晚些时候它将移动(2.0.2 @beta将具有更正的名称 "velocity-animate" ) .

相关问题