webpack.co.nfig.jsにおけるエージェント構成は、ドメイン間のアクセスとして使用される.
4282 ワード
devServer: {
port:8001,
contentBase: './',// boolean | string | array, static file location
compress: true, // enable gzip compression
historyApiFallback: true, // true for index.html upon 404, object for multiple paths
hot: true, // hot module replacement. Depends on HotModuleReplacementPlugin
https: false, // true for self-signed, object for cert authority
noInfo: true, // only errors & warns on hot reload
host:'192.168.0.56',
proxy: [
{
context: ['/dist/*'],
target: 'http://localhost',
changeOrigin: true,
secure: false
},
]
},
全体のwenback配置var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var node_dir = path.join(__dirname, './node_modules/');
var htmlPlugin = require('html-webpack-plugin');
//
var isProduction = process.env.NODE_ENV === 'production';
if(process.env.NODE_ENV)
{
console.log("--------"+process.env.NODE_ENV.toString());
}
console.log("--------"+isProduction);
module.exports = {
entry: {
app: ['./src/app.jsx']
},
output: {
path: path.join(__dirname, '/dist'),
filename: 'bundle.js',
publicPath: isProduction?'../':'/dist/',
chunkFilename: '[name].chunk.js'
},
module: {
loaders: [{
// test: /\.jsx?$/,
test: /(\.jsx|\.js)$/,
loader: 'babel',
query: {
presets: ['es2015', 'react','es2017']
},
exclude: node_dir
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css')
}, {
test: /\.less$/,
loader: ExtractTextPlugin.extract('style', 'css!less')
},
{
test: /\.(png|jpe?g|gif)$/,
loader: 'url?limit=1024000&name=img/[name].[ext]'
},
{
test: /\.(woff|woff2|ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file?limit=1&name=fonts/[name].[ext]'
}]
},
resolve: {
extensions: ['', '.js', '.jsx', '.json', '.css', '.less'],
alias: {
// libs: path.join(__dirname, "./web/libs"),
style: path.join(__dirname, "./src/style"),
img: path.join(__dirname, "./src/img"),
view: path.join(__dirname, "./src/view"),
utils: path.join(__dirname, "./src/util")
}
},
devServer: {
port:8001,
contentBase: './',// boolean | string | array, static file location
compress: true, // enable gzip compression
historyApiFallback: true, // true for index.html upon 404, object for multiple paths
hot: true, // hot module replacement. Depends on HotModuleReplacementPlugin
https: false, // true for self-signed, object for cert authority
noInfo: true, // only errors & warns on hot reload
host:'192.168.0.56',
proxy: [
{
context: ['/dist/*'],
target: 'http://localhost',
changeOrigin: true,
secure: false
},
]
},
plugins: [
new webpack.ProvidePlugin({
React: 'react', // react
ReactDOM: 'react-dom'
}),
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('css/[name].css'),
// new htmlPlugin({
// template: './web/template.html',
// filename: 'index.html'
// }),
new webpack.HotModuleReplacementPlugin()
],
devtool: isProduction ? null : 'source-map'
};