mirror of
https://github.com/Febbweiss/springboot-react-webpack.git
synced 2026-03-04 14:15:36 +00:00
Feature: add webpack dev server
This commit is contained in:
@@ -28,9 +28,8 @@
|
|||||||
"webpack-dev-server": "^1.14.1"
|
"webpack-dev-server": "^1.14.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "webpack-dev-server --hot --inline --devtool eval --progress --colors --content-base build --port 9999",
|
"watch": "NODE_ENV=development webpack-dev-server --hot --inline",
|
||||||
"dev-build": "webpack -d --progress --colors",
|
"dev-build": "NODE_ENV=development webpack --d --progress --colors",
|
||||||
"prod-build": "webpack -d -p --colors",
|
"prod-build": "webpack -d -p --colors"
|
||||||
"watch": "webpack --watch -d"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ var path = require('path'),
|
|||||||
HtmlWebpackPlugin = require('html-webpack-plugin');
|
HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
|
||||||
var source_dir = __dirname + '/src/main/resources/static',
|
var source_dir = __dirname + '/src/main/resources/static',
|
||||||
node_dir = __dirname + '/node_modules';
|
node_dir = __dirname + '/node_modules',
|
||||||
|
dev_port = 9090;
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
entry: {
|
entry: {
|
||||||
@@ -19,7 +20,7 @@ var config = {
|
|||||||
cache: true,
|
cache: true,
|
||||||
debug: true,
|
debug: true,
|
||||||
output: {
|
output: {
|
||||||
path: './target/classes/static',
|
path: __dirname + '/target/classes/static',
|
||||||
filename: 'js/[name].bundle.js',
|
filename: 'js/[name].bundle.js',
|
||||||
publicPath: '/'
|
publicPath: '/'
|
||||||
},
|
},
|
||||||
@@ -33,6 +34,10 @@ var config = {
|
|||||||
hash: true
|
hash: true
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
devServer: {
|
||||||
|
port: dev_port,
|
||||||
|
publicPath: 'http://localhost:' + dev_port + '/'
|
||||||
|
},
|
||||||
module: {
|
module: {
|
||||||
loaders: [
|
loaders: [
|
||||||
{
|
{
|
||||||
@@ -82,4 +87,10 @@ var config = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var env = process.env.NODE_ENV;
|
||||||
|
|
||||||
|
if (env === 'development') {
|
||||||
|
config.output.publicPath = 'http://localhost:' + dev_port + '/';
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = config;
|
module.exports = config;
|
||||||
Reference in New Issue
Block a user