1
我正在配置簡單的webpack堆棧,它可以工作,但問題是它會在每次更改文件時重新加載應用程序。有沒有辦法在每次文件更改時關閉重新加載?我想手動重新加載頁面,我也沒有使用熱重載,我不想使用它。禁用webpack重裝
對於服務器我使用的文件:
/*eslint no-console:0 */
'use strict';
require('core-js/fn/object/assign');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const config = require('./webpack.config');
const open = require('open');
new WebpackDevServer(webpack(config), config.devServer)
.listen(config.port, 'localhost', (err) => {
if (err) {
console.log(err);
}
console.log('Listening at localhost:' + config.port);
console.log('Opening your system browser...');
open('http://localhost:' + config.port + '/webpack-dev-server/');
});
而對於的WebPack配置這些都是一些部分:
module.exports = {
additionalPaths: additionalPaths,
port: defaultSettings.port,
debug: true,
devtool: 'eval',
output: {
path: path.join(__dirname, '/../dist'),
filename: '[name].js',
publicPath: defaultSettings.publicPath
},
devServer: {
contentBase: './src/',
historyApiFallback: true,
hot: false,
port: defaultSettings.port,
publicPath: defaultSettings.publicPath,
noInfo: false
},
resolve: {
extensions: ['', '.js', '.jsx'],
alias: {
plugins: `${defaultSettings.srcPath}/../plugins`,
core: `${defaultSettings.srcPath}/../core`
}
}
};
和DEV配置:
let config = Object.assign({}, baseConfig, {
entry: {
start: ['./src/index'],
vendors: [],
core: './plugins/lunchbadger-core/index',
plugins: infoFile.plugins.map((plugin) => { return ('./plugins/lunchbadger-' + plugin); })
},
cache: true,
devtool: 'eval',
plugins: [
new webpack.NoErrorsPlugin()
],
module: defaultSettings.getDefaultModules()
});
是的,這可能會工作,我會檢查 – Kamil