【发布时间】:2019-03-25 15:02:35
【问题描述】:
我正在尝试添加不适用于 Vue-cli 3 的 webpack.ProvidePlugin。
我还尝试将lodash 设置为全局导入(因此我不必在每个商店模块中导入它)。
vue.config
const webpack = require("webpack");
module.exports = {
configureWebpack: {
plugins: [new webpack.ProvidePlugin({ _: "lodash" })]
}
};
构建错误:
Module Warning (from ./node_modules/eslint-loader/index.js):
error: '_' is not defined (no-undef) at src/store/modules/templates.js:24:10:
22 | export default Object.assign({}, base, {
23 | namespaced: true,
> 24 | state: _.cloneDeep(initialState),
| ^
25 | mutations: {
26 | addTemplate(state, template) {
27 | if (!template) throw new Error("template is missing");
我在将行添加到vue.config 后构建了项目,他们给了我上述错误。
【问题讨论】: