1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00

Make build produce a production build

Closes #1
This commit is contained in:
ivaosthu 2016-11-10 22:49:28 +01:00
parent 9ef5598fd5
commit 7f8ec4262d
2 changed files with 21 additions and 32 deletions

View File

@ -20,9 +20,9 @@
}, },
"scripts": { "scripts": {
"build": "npm run build:assets && npm run build:html", "build": "npm run build:assets && npm run build:html",
"build:assets": "webpack -p", "build:assets": "NODE_ENV=production webpack -p",
"build:html": "cp public/*.* dist/.", "build:html": "cp public/*.* dist/.",
"start": "webpack-dev-server --config webpack.config.js --hot --progress --colors --port 3000", "start": "NODE_ENV=development webpack-dev-server --config webpack.config.js --hot --progress --colors --port 3000",
"start:api": "json-server --watch mock-api.json -p 3001", "start:api": "json-server --watch mock-api.json -p 3001",
"lint": "eslint . --ext=js,jsx", "lint": "eslint . --ext=js,jsx",
"test": "echo 'no test'", "test": "echo 'no test'",

View File

@ -5,12 +5,24 @@ const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin');
const entry = ['./src/index'];
const plugins = [new ExtractTextPlugin('bundle.css', { allChunks: true })];
if (process.env.NODE_ENV === 'development') {
entry.push('webpack-dev-server/client?http://localhost:3000');
entry.push('webpack/hot/only-dev-server');
plugins.push(new webpack.HotModuleReplacementPlugin());
} else {
plugins.push(new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}));
}
module.exports = { module.exports = {
entry: [ entry,
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./src/index',
],
resolve: { resolve: {
root: [path.join(__dirname, 'src')], root: [path.join(__dirname, 'src')],
@ -39,10 +51,7 @@ module.exports = {
], ],
}, },
plugins: [ plugins,
new ExtractTextPlugin('bundle.css', { allChunks: true }),
new webpack.HotModuleReplacementPlugin(),
],
sassLoader: { sassLoader: {
data: '@import "theme/_config.scss";', data: '@import "theme/_config.scss";',
@ -57,27 +66,7 @@ module.exports = {
devServer: { devServer: {
proxy: { proxy: {
'/features': { '/api': {
target: 'http://localhost:4242',
secure: false,
},
'/strategies': {
target: 'http://localhost:4242',
secure: false,
},
'/archive': {
target: 'http://localhost:4242',
secure: false,
},
'/events': {
target: 'http://localhost:4242',
secure: false,
},
'/metrics': {
target: 'http://localhost:4242',
secure: false,
},
'/client': {
target: 'http://localhost:4242', target: 'http://localhost:4242',
secure: false, secure: false,
}, },