swiper failed to bundle in react app,help~

Created on 17 Nov 2017  路  8Comments  路  Source: nolimits4web/swiper

$ react-scripts build
Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file:

    ./node_modules/swiper/dist/js/swiper.esm.bundle.js:15

Read more here: http://bit.ly/2tRViJ9

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Most helpful comment

Just import the swiper with the absolute path.
import Swiper from 'swiper/dist/js/swiper.js'

All 8 comments

Have the same thing..

Same problem

Hi nolimis4web!

Tried your recommendation, but unfortunately it doesn't work.

Here is my piece of code for production build:
` {

     test: /\.(js|jsx|mjs)$/,
     include: paths.appSrc,
     exclude: /node_modules\/(?!(dom7|swiper)\/).*/,
     loader: require.resolve('babel-loader'),
     options: {
        compact: true,
        },
      },`

Cheers,
Chris

Hi,

I just installed Swiper to a freshly installed create-react-app, and I receive this exact error, when I tried to 'npm run build'.

Any idea to solve this?

Best regards,
Richard

Same problem, and try the above scheme is invalid

alias: {
      swiper$: 'swiper/dist/js/swiper.js',
      dom7$: 'dom7/dist/dom7.js',
      // Support React Native Web
      // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
      'react-native': 'react-native-web',
    },

The above webpack configuration can be resolved, but I'm still a little confused about why.

@Riprios @DarkChris86 @nolimits4web

Just import the swiper with the absolute path.
import Swiper from 'swiper/dist/js/swiper.js'

Was this page helpful?
0 / 5 - 0 ratings