Giter Site home page Giter Site logo

Comments (12)

dan-gamble avatar dan-gamble commented on April 28, 2024 4

I'm not 100% sure what semantic ui needs from the provide plugin but you can use it like this:

In your nuxt.config.js

const webpack = require('webpack')

module.exports = {
  build: {
    plugins: [
      new webpack.ProvidePlugin({
        '$': 'jquery',
        '_': 'lodash'
        // ...etc.
      })
    ]
  }
}

from nuxt.js.

fortil avatar fortil commented on April 28, 2024 1

@dan-gamble doesn't work to me... with what versión works?

from nuxt.js.

limasierra avatar limasierra commented on April 28, 2024 1

Hi,

I'm also having this issue. npm run dev gives me

ERROR

  Error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type s  tring

  - path.js:28 assertPath
    path.js:28:11

  - path.js:1469 extname
    path.js:1469:5

  - builder.js:71 _.uniqBy.options.plugins.map
    [cve-miner-gui]/[nuxt]/lib/builder/builder.js:71:48

  - Array.map

  - builder.js:69 Builder.get plugins [as plugins]
    [cve-miner-gui]/[nuxt]/lib/builder/builder.js:69:28

  - builder.js:256 Builder.generateRoutesAndFiles
    [cve-miner-gui]/[nuxt]/lib/builder/builder.js:256:21

  - builder.js:165 Builder.build
    [cve-miner-gui]/[nuxt]/lib/builder/builder.js:165:16

What I've done in nuxt.config.js:

const webpack = require('webpack')

module.exports = {
  [...]
  plugins: [
    { src: '~plugins/myOtherPlugin.js', ssr: false },
    new webpack.ProvidePlugin({
        '$': 'jquery',
      })
  ],
  [...]

On top of that, the Nuxt.js FAQ page is at odds with the API docs:

Bottom line: I think the documentation on the FAQ page is out of date, but I cannot figure out how to solve the problem.

from nuxt.js.

limasierra avatar limasierra commented on April 28, 2024 1

Philcal, I just noticed something!

I placed the webpack.ProvidePlugin in

module.exports = {
  plugins: [ /* here */ ]
}

whereas it should probably be in

module.exports = {
  plugins: [ /* not here */ ],
  build: {
    plugins: [ /* but here! */ ]
  }
}

An example can be found in this issue: #1319 .
On top of that, the FAQ page I mentioned earlier also states this. I think I just missed that it should be an a different plugins array and thus used it wrongly. You may be doing the same?

hth

from nuxt.js.

Atinux avatar Atinux commented on April 28, 2024

@tsvetant can you confirm it's working?

from nuxt.js.

tsvetowntopalov avatar tsvetowntopalov commented on April 28, 2024

Yes, it worked ! I just needed to put the jquery to get semantic-ui to work without extra effort

from nuxt.js.

c5n8 avatar c5n8 commented on April 28, 2024

@tsvetowntopalov how do you include semantic ui to nuxt?

from nuxt.js.

philcal avatar philcal commented on April 28, 2024

Did you find a solution to this problem?

from nuxt.js.

limasierra avatar limasierra commented on April 28, 2024

No, I did not.

I needed JQuery, and ended up doing this in my component:

mounted () {
    if (process.browser) {
      let { $ } = window
      $(window).scroll(function () {
        if ($(this).scrollTop() > 100) {
          $('#back-to-top').fadeIn()
        } else {
          $('#back-to-top').fadeOut()
        }
      })
    }
  }

...along with this in my layout:

  head: {
    script: [
      { src: '/js/jquery-3.2.1.min.js' }
    ]
  }

You may be able to solve your problem in a similar fashion :)

from nuxt.js.

limasierra avatar limasierra commented on April 28, 2024

@philcal I investigated the issue further.

The solution suggested in the FAQ works as expected.

The problem was caused by Eslint, namely error '$' is not defined no-undef. You can quickly check if this is the problem by amending the rules in your .eslintrc.js file: 'no-unreachable': 'warn'. Then, it should work.

If you want to keep things clean, I suggest you try to merge the eslint config from a newer version of Nuxt, where this webpack stuff works out of the box :)

from nuxt.js.

akdasa avatar akdasa commented on April 28, 2024
module.exports = {
  build: {
    plugins: [
      new webpack.ProvidePlugin({
        '$': 'jquery',
        '_': 'lodash'
        // ...etc.
      })
    ]
  }
}

Looks like it will inject jquery, lodash at every page. Am I right?

from nuxt.js.

lock avatar lock commented on April 28, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from nuxt.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.