dimanche 16 juin 2019

How to add script file via webpack

When I run "npm run prod" the contents of my JS files ( jquery.cssmap.min.js ) are well integrated into my final file ( frontend.js ). But when I want to use them I come across

jQuery.Deferred exception: $(...).CSSMap is not a function TypeError: 
$(...).CSSMap is not a function" errors

I have the same error with many other script

In short if I put the files directly in the header of my site it works but when I compile them they do not work.

My webpack.mix.js :

const mix = require('laravel-mix');


mix.setPublicPath('public');

mix.sass('resources/sass/frontend/app.scss', 'css/frontend.css')
/// .sass('resources/sass/frontend/_custom.scss', 'css/frontend.css')
.sass('resources/sass/backend/app.scss', 'css/backend.css')
.js(['resources/js/frontend/app.js',
'resources/js/jquery.cssmap.min.js'
],
    'js/frontend.js')
.js([
    'resources/js/backend/before.js',
    'resources/js/backend/app.js',
    'resources/js/backend/after.js'
], 'js/backend.js')
.extract([
    'jquery',
    'bootstrap',
    'popper.js/dist/umd/popper',

]);

if (mix.inProduction() || process.env.npm_lifecycle_event !== 'hot') {
mix.version();
}

JQuery is at the top of the top of my header and it is loaded.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire