私はReactJS-Appを開発しており、これはPHPバックエンドによって提供されます。私のローカルマシンでは、プロジェクトのルートを指す仮想ホストでMAMPをセットアップし、webpackを使用してReact-Appをバンドルします。ReactJS PHPバックエンド上のアプリケーション - ローカルマシンでホットリロードする方法?
ホットリロードで作業することを本当に楽しんでいるので、今すぐwebpack dev-serverをプロキシMAMPに使用して、反応ホットローディング機能を利用しようとしています。
私はまだ動作していないので、誰かが設定を手伝ってくれることを願っています。それとも、基本的に私のアプローチではないのですか?とにかく、これで私を助けてくれたら嬉しいよ。前もって感謝します!これまでのwebpackの設定はこれです:
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const StyleLintPlugin = require('stylelint-webpack-plugin');
module.exports = {
devtool: 'cheap-module-source-map',
devServer: {
port: 3000,
proxy: {
'*': {
target: 'http://my-virtual-host.dev:8888/',
}
}
},
entry: [
'./src/app.jsx'
],
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js',
publicPath: 'http://localhost:3000/build/'
},
resolve: {
extensions: ['.js', '.jsx']
},
module: {
loaders: [
{
enforce: 'pre',
test: /\.jsx?$/,
include: [
path.resolve(__dirname, 'src'),
],
loader: 'eslint-loader',
},
{
test: /\.jsx?$/,
include: [
path.resolve(__dirname, 'src'),
],
loader: 'react-hot-loader'
},
{
test: /\.jsx?$/,
include: [
path.resolve(__dirname, 'src'),
],
loader: 'babel-loader',
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: { importLoaders: 1 },
},
'postcss-loader',
],
}),
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new ExtractTextPlugin('bundle.css'),
new StyleLintPlugin({
configFile: '.stylelintrc',
context: 'src',
files: '**/*.pcss'
})
]
};
これはあなたに役立ちます:https://webpack.js.org/guides/hot-module-replacement/ – Axnyff
ありがとう@Axnyff!私はこの問題を深く掘り下げてきました。何が私を混乱させているのかは、それが基本的にどのように働いているかですそれはMAMPが私のindex.htmlを提供し、webpack devサーバーサーバーが資産を提供していますか?それとも、MAMPのindex.htmlを "取る"がすべてを処理しているwebpack devサーバーですか?ありがとうございました! – nielsG
@Axnyff私は私の質問を解決しました、下記のコメントを参照してください!さらなる進出を手伝ってくれてありがとう! – nielsG