jquery-ui和webpack,如何将其管理到模块中? [英] jquery-ui and webpack, how to manage it into module?

查看:109
本文介绍了jquery-ui和webpack,如何将其管理到模块中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

知道如何处理吗?我的意思是jquery-ui似乎不是amd,而且我不知道如何管理它,知道吗?

any idea how to deal with that ? I mean jquery-ui seems not to be amd and I don't know how to manage that , any idea ?

推荐答案

很幸运,我昨天才这样做,很简单.

youre in luck I did this just that yesterday, it's rather easy.

npm install --save jquery jquery-ui

确保您拥有别名别名以使用webpack.config.js中的插件进行解析

Make sure that you have jquery aliased to resolve with the plugin in the webpack.config.js

...
plugins: [
    new webpack.ProvidePlugin({
      "$":"jquery",
      "jQuery":"jquery",
      "window.jQuery":"jquery"
    }),
...

然后在webpack.config.js中包含两个别名

Then include two aliases in the webpack.config.js

  1. node_modules文件夹
  2. jquery-ui文件夹

``````

resolve : {
    alias: {
      // bind version of jquery-ui
      "jquery-ui": "jquery-ui/jquery-ui.js",      
      // bind to modules;
      modules: path.join(__dirname, "node_modules"),

确保首先将jQuery加载到您的应用启动文件中.

Make sure that jquery gets loaded first in your app startup file.

var $ = require("jquery"),
        require("jquery-ui");

如果需要使用主题,请配置css-loader和file-loader.不要忘记npm安装那些装载程序.

If you need to use a theme configure the css-loader and the file-loader. Don't forget to npm install those loaders.

module: {
    loaders: [
      { test: /\.css$/, loader: "style!css" },
      { test: /\.(jpe?g|png|gif)$/i, loader:"file" },

并在您的应用启动文件中使用.

And use in your app startup file.

require("modules/jquery-ui/themes/black-tie/jquery-ui.css");
require("modules/jquery-ui/themes/black-tie/jquery-ui.theme.css");

这篇关于jquery-ui和webpack,如何将其管理到模块中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆