parent
99443e25de
commit
dd1e32ba0b
4 changed files with 76 additions and 12 deletions
@ -1,15 +1,30 @@ |
||||
var webpack = require('webpack'); |
||||
var WebpackDevServer = require('webpack-dev-server'); |
||||
var config = require('./webpack.config'); |
||||
|
||||
new WebpackDevServer(webpack(config), { |
||||
publicPath: config.output.publicPath, |
||||
hot: true, |
||||
historyApiFallback: true |
||||
}).listen(3000, 'localhost', function (err, result) { |
||||
const path = require('path'); |
||||
const express = require('express'); |
||||
const bodyParser = require('body-parser'); |
||||
|
||||
const app = express(); |
||||
|
||||
const host = 'http://localhost'; |
||||
const port = 3000; |
||||
|
||||
app.use(bodyParser.urlencoded({ extended: false })); |
||||
|
||||
app.use('/static', express.static(path.join(__dirname, 'dist'))); |
||||
app.use('/assets', express.static(path.join(__dirname, 'assets'))); |
||||
app.get('/', (req, res) => { |
||||
res.sendFile(path.join(__dirname, 'index.html')); |
||||
}); |
||||
|
||||
app.post('*', (req, res) => { |
||||
console.log("to: " + req.path); |
||||
console.log(Object.keys(req.body)[0]); |
||||
res.end(); |
||||
}); |
||||
|
||||
app.listen(port, 'localhost', (err) => { |
||||
if (err) { |
||||
console.log(err); |
||||
return; |
||||
} |
||||
|
||||
console.log('Listening at localhost:3000'); |
||||
console.info('==> Listening on port %s. Open up %s:%s/ in your browser.', port, host, port); |
||||
}); |
||||
|
@ -0,0 +1,16 @@ |
||||
var webpack = require('webpack'); |
||||
var WebpackDevServer = require('webpack-dev-server'); |
||||
var config = require('./webpack.config'); |
||||
|
||||
new WebpackDevServer(webpack(config), { |
||||
publicPath: config.output.publicPath, |
||||
hot: true, |
||||
historyApiFallback: true, |
||||
noInfo: true |
||||
}).listen(3000, 'localhost', function (err, result) { |
||||
if (err) { |
||||
console.log(err); |
||||
} |
||||
|
||||
console.log('Listening at localhost:3000'); |
||||
}); |
@ -0,0 +1,30 @@ |
||||
var path = require('path'); |
||||
var webpack = require('webpack'); |
||||
|
||||
module.exports = { |
||||
devtool: 'source-map', |
||||
entry: [ |
||||
'./src/index' |
||||
], |
||||
output: { |
||||
path: path.join(__dirname, 'dist'), |
||||
filename: 'bundle.js', |
||||
publicPath: '/static/' |
||||
}, |
||||
plugins: [ |
||||
new webpack.HotModuleReplacementPlugin(), |
||||
new webpack.optimize.UglifyJsPlugin({ |
||||
compressor: { |
||||
warnings: false |
||||
} |
||||
}), |
||||
new webpack.NoErrorsPlugin() |
||||
], |
||||
module: { |
||||
loaders: [{ |
||||
test: /\.js$/, |
||||
loaders: ['babel'], |
||||
include: path.join(__dirname, 'src') |
||||
}] |
||||
} |
||||
}; |
Loading…
Reference in new issue