如何解决未捕获的错误:define 不能在 symfony/webpack-encore 和 mdboostrap 中间接使用
我收到错误
Uncaught Error: define cannot be used indirect
at __webpack_require__.amdD (amd define:2)
at mdb.lite.js:7639
at Object.<anonymous> (mdb.lite.js:7839)
at Object.<anonymous> (mdb.lite.js:7842)
at n (mdb.lite.js:36)
at Module.<anonymous> (mdb.lite.js:7848)
at n (mdb.lite.js:36)
at Object.<anonymous> (mdb.lite.js:7844)
at n (mdb.lite.js:36)
at mdb.lite.js:70
package.json
{
"devDependencies": {
"@fortawesome/fontawesome-free": "^5.15.3","@symfony/webpack-encore": "^1.1.2","exports-loader": "^2.0.0","expose-loader": "^2.0.0","file-loader": "^6.2.0","imports-loader": "^2.0.0","jquery": "^3.3.1","less": "^4.1.1","less-loader": "^8.0.0","sass": "^1.32.8","sass-loader": "^11.0.1","ts-loader": "^8.0.18","url-loader": "^4.1.1","webpack-notifier": "^1.6.0","jquery-validation": "1.19.3","jquery-ui": "1.12.1","cashify": "^2.5.0","jquery.cookie": "^1.4.1","jquery-form": "^4.3.0","bs-custom-file-input": "^1.3.4","uniform.js": "^2.2.2"
},"dependencies": {
"bootstrap": "^4.1.1","bootstrap-colorpicker": "^3.2.0","bootstrap-datepicker": "^1.9.0","bootstrap-daterangepicker": "^3.0.3","bootstrap-fileinput": "^4.4.8","chartjs": "^0.3.24","emojionearea": "^3.4.2","jarallax": "^1.12.5","jquery-migrate": "^3.3.2","js-cookie": "^2.2.0","mdbootstrap": "^4.19.2","mdbootstrap-pro": "git+https://oauth2:xxx@git.mdbootstrap.com/mdb/jquery/jq-pro.git#4.19.2","select2": "^4.0.6-rc.1","timeago": "^1.6.7"
},"license": "UNLICENSED","private": true,"scripts": {
"dev-server": "encore dev-server","dev": "encore dev","watch": "encore dev --watch","build": "encore production"
}
}
webpack.config.js
const Encore = require('@symfony/webpack-encore');
const Path = require('path');
Encore
.setOutputPath('./../../public/webpack/front')
.setPublicPath('/webpack/front')
.addEntry('js/app','./js/app.js')
.addStyleEntry('css/app','./scss/app.scss')
.splitEntryChunks()
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning(Encore.isProduction())
.autoProvidejQuery()
.enableSassLoader()
.enableLessLoader()
// .addExternals({
// jquery: 'jQuery'
// })
// .addPlugin(new webpack.ProvidePlugin({
// $: 'jquery',// jQuery: 'jquery',// 'window.jQuery': 'jquery',// }))
// .addLoader({
// test: require.resolve('jquery'),// use:[
// {
// loader: 'expose-loader',// options: 'jQuery'
// },// {
// loader: 'expose-loader',// options: 'jquery'
// },// options: '$'
// }
// ]
// })
;
let config = Encore.getWebpackConfig();
config.resolve.modules = [Path.resolve(__dirname,'node_modules')]; //default path to node_modules dir
module.exports = config;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。