https://teratail.com/questions/120211
の続きになります。
import React from 'react'; import { render } from 'react-dom'; import $ from "jquery"; import 'jquery-ui/themes/base/resizable.css'; window.jQuery = $; require('jquery-ui/ui/version'); require('jquery-ui/ui/plugin'); require('jquery-ui/ui/widget'); require('jquery-ui/ui/widgets/mouse'); require('jquery-ui/ui/widgets/resizable'); class Test extends React.Component { componentDidMount() { this.$left = $(this.refs.left); console.log(this.$left.resizable); this.$left.resizable() } render() { return ( <div> <div className="left" ref="left">aaa</div> </div> ) } } render(<Test />, document.getElementById('root'));
jquery-uiを読み込むことはおかげさまで出来たのですが、
css-loaderを使用しており(すいません、正直この機能自体深く理解しておらず製作の決まりで使用しなければならず・・)
className={theme.hoge}などとしてTest.hoge-jaie3NR3のように自動で
css名がかぶらないようになっております。
これがjquery-uiのcssにも反映されており、
htmlにはclass="ui-resizable-handle"と付与されるのですが、
cssの方ではui-resizable-handle-NEJJ3ij4---erf(例)のように
なっており、cssがあたっていない状態になってしまいます。
こちらを改善するにはどのような手法が考えられますでしょうか?
//webpack設定ファイルを追記
const path = require('path'); const webpack = require('webpack'); const settings = { entry: { test: [ "react-hot-loader/patch", "./src/frontend/test.js" ] }, output: { filename: "[name].js", publicPath: "/", path: path.resolve("build") }, resolve: { extensions: [".js", ".json", ".css"] }, devtool: "eval-source-map", module: { rules: [ { test: /.js?$/, loader: 'babel-loader', options: { presets: [ ["es2015", { modules: false }], "stage-2", "react" ], plugins: [ "transform-node-env-inline" ], env: { development: { plugins: ["react-hot-loader/babel"] } } } }, { test: /.css$/, use: [ "style-loader", { loader: "css-loader", options: { modules: true, sourceMap: true, importLoaders: 1, localIdentName: "[name]--[local]--[hash:base64:8]" } }, "postcss-loader" // has separate config, see postcss.config.js nearby ] }, ] }, devServer: { contentBase: path.resolve("src/www"), publicPath: "http://localhost:3000/", // full URL is necessary for Hot Module Replacement if additional path will be added. quiet: false, hot: true, historyApiFallback: true, inline: true }, plugins: [ new webpack.HotModuleReplacementPlugin(), new webpack.NamedModulesPlugin(), new webpack.LoaderOptionsPlugin({ debug: true }), ], }; module.exports = settings;
追記:
やはり、css-loaderでマッピングされたクラス名だと
jsが反応しないようなので、jquery-uiのcssファイルだけcss-loaderが
きかないように出来ないかという方向性で検討してみたいと思いますのでいったんこちらは閉じさせていただきます。
回答1件
あなたの回答
tips
プレビュー