Search code examples
vue.jsecmascript-6symfony4polyfillswebpack-encore

IE not supporting VueJS - Symfony application


How to make work the VueJS - Symfony application in IE11?

I'm using Babel Encore.

Already checked available answers in Stack but not working for me. Also, tried import the @babel/polyfill directly to the JS which is not working either.

Here is the webpack.config.js configuration of my application

const {VueLoaderPlugin} = require('vue-loader');
let Encore = require('@symfony/webpack-encore');

Encore
    .setOutputPath('public/build/')
    .setPublicPath('/build')
    .cleanupOutputBeforeBuild()
    .enableSourceMaps(!Encore.isProduction())
    .addEntry('app', './assets/js/app.js')
    // .enableVueLoader()
    .addLoader({
        test: /\.vue$/,
        loader: 'vue-loader'
    })
    .enableBuildNotifications()
    // .configureBabel(() => {}, {
    //     useBuiltIns: 'entry',
    //     corejs: 3
    // })

    .addPlugin(new VueLoaderPlugin())
    .enableSassLoader()
    .enableVersioning(Encore.isProduction())
;


module.exports = Encore.getWebpackConfig();

Note: The IE browser now showing an error in the console SCRIPT1010: Expected identifier and showing a blank page.


Solution

  • Issue fixed by updating the configuration

    const {VueLoaderPlugin} = require('vue-loader');
    let Encore = require('@symfony/webpack-encore');
    
    Encore
      .setOutputPath('public/build/')
      .setPublicPath('/build')
      .cleanupOutputBeforeBuild()
      .enableSourceMaps(!Encore.isProduction())
      .addEntry('app', './assets/js/app.js')
      .addLoader({
          test: /\.vue$/,
          loader: 'vue-loader'
      })
      .enableBuildNotifications()
    
      .addPlugin(new VueLoaderPlugin())
      .enableSassLoader()
      .enableVersioning(Encore.isProduction())
     .configureBabel(function(babelConfig) {
        // add additional presets
        // babelConfig.presets.push('@babel/preset-flow');
    
        // no plugins are added by default, but you can add some
        // babelConfig.plugins.push('styled-jsx/babel');
      }, {
        // node_modules is not processed through Babel by default
        // but you can whitelist specific modules to process
        // includeNodeModules: ['foundation-sites'],
    
        // or completely control the exclude rule (note that you
        // can't use both "includeNodeModules" and "exclude" at
        // the same time)
        exclude: /loadash/
      });
    

    module.exports = Encore.getWebpackConfig();