vigetlabs / blendid

A delicious blend of gulp tasks combined into a configurable asset pipeline and static site builder
MIT License
4.97k stars 680 forks source link

Swiper 4 : Error with UglifyJS Unexpected token: name (w) #549

Closed xavianaxw closed 6 years ago

xavianaxw commented 6 years ago

I know this isn't a blendid issue but ...

I'm having issues compiling Swiper 4 for production where the error below will be thrown during compilation:

[12:05:58] gulp-notify: [Error running Gulp] Error:
app.js from UglifyJs
Unexpected token:
name (w) [app.js:54608,4]

There's an issue on it from the swiper repo regarding this at #2206 where it states it is using ES-Next so I am required to use babel-loader or import 'correct version' with import Swiper from 'swiper/dist/js/swiper.js';

My javascript config now currently looks like this:

javascripts: {
    entry: {
      // files paths are relative to
      // javascripts.dest in path-config.json
      app: ["./app.js"],
    },
    hot: {
      react: true,
    },
    babel: {
      presets: ["react-app"],
    },
  },

How should I go about to fix this?

xavianaxw commented 6 years ago
babelLoader: {
    // "test" is derived from TASK_CONFIG.javascripts.extensions
    // "options" is derived from TASK_CONFIG.javascripts.babel
    loader: "babel-loader",
    exclude: /node_modules\/(?!(dom7|swiper)\/).*/,
},

in task-config.js fixed this for me