У меня есть несколько записей, которые все импортируют jQuery. Это дает мне сообщение об ошибке «Несколько блоков генерируют ресурсы для одного и того же имени файла», я предполагаю, что это связано с тем, что jQuery импортируется в каждый файл. Я прочитал документацию Webpack по зависимостям, но она не сработала, когда я попробовал то, что есть в документации. Вот мой текущий конфиг:
const path = require('path');
module.exports = {
entry: {
content: './src/content.js',
header: './src/header.js',
frontpage:'./src/frontpage.js',
footer:'./src/footer.js',
remove:'./src/remove.js',
results:'./src/results.js'
},
output: {
filename: 'content.js',
path: path.resolve(__dirname, 'dist'),
}
};
Из того, что я читал из документов, это должно выглядеть так, но оно продолжало выдавать ошибки, говоря:
Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.entry should be one of these:
function | object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string]
-> The entry point(s) of the compilation.
Details:
* configuration.entry['frontpage'] should be a string.
-> The string is resolved to a module which is loaded upon startup.
* configuration.entry['frontpage'] should be an array:
[non-empty string]
-> A non-empty array of non-empty strings
* configuration.entry['frontpage'] should be one of these:
[non-empty string]
-> All modules are loaded upon startup. The last one is exported.
* configuration.entry['frontpage'] should be one of these:
non-empty string | [non-empty string]
-> An entry point with name
Вот эта конфигурация
const path = require('path');
const jquery = require('jquery')
module.exports = {
entry: {
content: { import: './src/content.js', dependOn: 'shared' },
header: { import: './src/header.js', dependOn: 'shared' },
frontpage: { import: './src/frontpage.js', dependOn: 'shared' },
footer: { import: './src/footer.js', dependOn: 'shared' },
remove: { import: './src/remove.js', dependOn: 'shared' },
results: { import: './src/results.js', dependOn: 'shared' },
shared: 'jquery'
},
output: {
filename: 'content.js',
path: path.resolve(__dirname, 'dist'),
}
};
что я делаю не так?
PS Я пытаюсь сохранить его в одном файле.
Это страница документа, о которой я говорю