无法使用Webpack / Webpackencore的可恢复J

我已经在纱线中安装了Resumablejs,并且在node_module文件夹中看到了它。

  

Webpack.config.js

Encore
    // directory where compiled assets will be stored
    .setOutputPath('public/build/')
    // public path used by the web server to access the output path
    .setPublicPath('/build')
    // only needed for CDN's or sub-directory deploy
    //.setManifestKeyPrefix('build/')

    /*
     * ENTRY CONFIG
     *
     * Add 1 entry for each "page" of your app
     * (including one that's included on every page - e.g. "app")
     *
     * Each entry will result in one JavaScript file (e.g. app.js)
     * and one CSS file (e.g. app.css) if your JavaScript imports CSS.
     */
    .addEntry('app','./assets/js/app.js')

    ....

var config = Encore.getWebpackConfig();
var path = require('path');

config.resolve.alias = {
'jquery': path.resolve(__dirname,'node_modules/jquery/src/jquery'),'resumablejs': path.resolve(__dirname,'node_modules/resumablejs/resumable')
};

module.exports = config;
  

package.json

   "dependencies": {
    ...
     "resumablejs": "^1.1.0",...
   }
  

app.js

/*
 * Welcome to your app's main JavaScript file!
 *
 * We recommend including the built version of this JavaScript file
 * (and its CSS file) in your base layout (base.html.twig).
 */

// any CSS you require will output into a single css file (app.css in this case)
require('../css/app.scss');
const $ = require('jquery');
global.$ = global.jQuery = $;

require('resumablejs');
...

import './EntriesJs';
  

EntriesJs

import AppScripts from './js/appScripts';

export {
    AppScripts
}

在我的app.js中,我已将其声明为require('resumablejs');,然后在我的文件中要像这样使用它:

module.exports = function (uploadJs) {
    return filesUploadScript();
};

function filesUploadScript() {
    (function () {

        console.log('js loaded...');

        var uploaderWidgetProperties = $('#_f-uploader-widget-properties');

        var r = new Resumable({ ... });

但此时我遇到以下错误:

Uncaught ReferenceError: Resumable is not defined

我很难理解Webpack,因此任何帮助都会很棒。

w52kdm 回答:无法使用Webpack / Webpackencore的可恢复J

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3150582.html

大家都在问