我正在构建基于API的应用程序。后端框架是PHP symfony,我使用最新的webpack反应。我遇到的问题是,当我对代码进行更改时,我无法获得--watch选项来重新加载。也不知道为什么但建设应用也花了太长时间......
有人知道问题出在哪里吗?
这是我的配置文件:
var path = require('path');
var webpack = require('webpack');
var devConfig = require('./webpack.config');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var config = {
devtool: 'source-map',
entry: {
app: './app/index',
vendor: devConfig.entry.vendor
},
resolve: {alias: {}},
output: {
path: path.join(__dirname, '/../../../../../../../public_html/pos-interface/'),
filename: 'bundle.js',
publicPath: './'
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
},
"require.specified": "require.resolve"
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new ExtractTextPlugin("styles.css"),
new webpack.HotModuleReplacementPlugin(),
new webpack.ProvidePlugin({
'$': "jquery",
'jQuery': "jquery",
'window.jQuery': "jquery",
'window.$': 'jquery'
}),
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js', Infinity),
],
devServer: {
historyApiFallback: true,
},
module: {
noParse: [],
loaders: [
{
test: /\.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'app')
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
},
{
test: /\.(png|jpg|gif)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=100000'
},
{
test: /\.(eot|com|json|ttf|woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
}
]
}
};
module.exports = config;
这是我用来启动webpack的命令
./node_modules/.bin/webpack --config webpack.config.js --watch