Adding class to `styleName` and then adding class to CSS file does not work with HMR
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- javascript, react, sass, webpack
- 領域
- build-system, frontend, tooling
調査の方向性
提供された webpack 設定から始め、特に react-css-modules の HMR 設定と SCSS loader チェーンを確認します。styleName クラスを追加してからスタイルシートでそれを定義する一連の手順を再現し、スタイルシートの変更がモジュールの更新に到達するかを追跡します。JavaScript ファイルを再保存しなくても CSS のみの編集で実行中のページが更新されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
I have this all setup and working and HMR will work except for in one use case. If you first add a class to styleName and then add the class to your css file HMR will not work. You need to go back to the JS file and re-save that file. This is the case no matter what handleMissingStyleName is set to. I have tried changing a number of settings in my Webpack config, but no luck. Any ideas are greatly appreciated. This is my Webpack config if that helps:
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const WriteFilePlugin = require('write-file-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
module.exports = (env, argv) => {
return {
context: path.resolve(__dirname, 'src'),
entry: './index.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'module.min.js'
},
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: false
}),
new OptimizeCSSAssetsPlugin({})
]
},
resolve: {
alias: {
react: 'preact-compat',
'react-dom': 'preact-compat',
'create-react-class': 'preact-compat/lib/create-react-class',
'react-dom-factories': 'preact-compat/lib/react-dom-factories'
}
},
module: {
rules: [
{
test: /\.scss$/,
use: [
argv.mode !== 'production'
? 'style-loader'
: MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: argv.mode === 'production' ? false : true,
importLoader: 2,
modules: true,
localIdentName:
argv.mode !== 'production'
? '[local]-[hash:base64]'
: '[hash:base64]'
}
},
{
loader: 'resolve-url-loader'
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
plugins: [
require('autoprefixer')({
browsers: ['last 4 versions']
})
]
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
data: '@import "variables"; @import "mixins";',
includePaths: [path.resolve(__dirname, './src/style')]
}
}
]
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
'@babel/plugin-proposal-class-properties',
['transform-react-jsx', { pragma: 'h' }],
[
'react-css-modules',
{
context: path.resolve(__dirname, 'src'),
webpackHotModuleReloading: true,
handleMissingStyleName: 'ignore',
generateScopedName:
argv.mode !== 'production'
? '[local]-[hash:base64]'
: '[hash:base64]',
filetypes: {
'.scss': {
syntax: 'postcss-scss'
}
}
}
]
]
}
}
},
{
test: /\.json$/,
use: 'json-loader'
},
{
test: /\.(xml|html|txt|md)$/,
use: 'raw-loader'
},
{
test: /\.(woff2?|ttf|eot|jpe?g|png|gif)(\?.*)?$/i,
use:
argv.mode === 'production'
? 'file-loader?name=[name].[ext]'
: 'url-loader'
},
{
test: /\.svg$/,
oneOf: [
{
include: [/css|non-inline-svg/],
use:
argv.mode === 'production'
? 'file-loader?name=[name].[ext]'
: 'url-loader'
},
{
exclude: [/css|non-inline-svg/],
loader: 'svg-inline-loader'
}
]
}
]
},
plugins: [
new CleanWebpackPlugin(['build/**']),
new HtmlWebpackPlugin({
template: './index.html',
minify: { collapseWhitespace: true }
}),
new HtmlWebpackPlugin({
template: './module.html',
filename: 'module.html',
inject: false,
minify: { collapseWhitespace: true }
}),
new WriteFilePlugin(),
new MiniCssExtractPlugin({
filename: 'module.min.css'
}),
new CopyWebpackPlugin([
{ from: './manifest.json', to: './' },
{ from: './favicon.ico', to: './' }
])
],
devServer: {
port: process.env.PORT || 8080,
host: 'localhost',
publicPath: '/',
contentBase: './src',
historyApiFallback: true,
open: true,
openPage: ''
}
}
}
- 主要言語
- JavaScript
- スター
- 2k
- フォーク
- 159
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
gajus/babel-plugin-react-css-modules のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
gajus/babel-plugin-react-css-modules#309 · リアクション 1 件 ·
-
doesn't work with windicss対応中かも @lili21 が 1774 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 20/100
gajus/babel-plugin-react-css-modules#306 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
gajus/babel-plugin-react-css-modules#304 · コメント 7 件 · リアクション 1 件 ·
gajus/babel-plugin-react-css-modules の issue をすべて見る
似ている issue
-
idnits3
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ietf-tools/idnits#363 ·
メンテナーはふだん 1 日以内に返信
-
prototype(verifier_token): map disallowed warning to contraindicated before composite precedence check対応中かも @drk-ram が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
agentrust-io/trace-spec#582 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 72/100
TheOdinProject/curriculum#31479 ·
メンテナーはふだん 1 日以内に返信
-
chore
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
SignalK/n2k-signalk#368 ·
メンテナーはふだん 1 日以内に返信