Webpack Encore - $ is not defined

前端 未结 2 1817
轮回少年
轮回少年 2021-02-09 13:12

I followed the documentation to make Webpack Encore work in my project. Imported js files in webpack.config.js work fine but I have an issue in page-specific js : $ is not

2条回答
  •  粉色の甜心
    2021-02-09 13:50

    You should use output.library: "Root" //Or what name you want config in webpack.config.js and in your entry js file do this:

    import $ from 'jquery'

    ... Your code of common entry file

    export {$};

    And you will access jquery like this:

    Root.$

提交回复
热议问题