我正在尝试添加webpack.ProvidePlugin
哪些不起作用Vue-cli 3
。我还尝试设置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
,他们给了我上述错误。