mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-29 08:20:21 +05:30
#216: do not require dev config for production builds
This commit is contained in:
parent
3eca56c837
commit
23a747e50a
@ -1,15 +1,15 @@
|
|||||||
/* eslint-env node */
|
/* eslint-env node */
|
||||||
|
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
var loaderUtils = require('loader-utils');
|
const loaderUtils = require('loader-utils');
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
var cssUrl = require('webpack-utils/cssUrl');
|
const cssUrl = require('webpack-utils/cssUrl');
|
||||||
var cssImport = require('postcss-import');
|
const cssImport = require('postcss-import');
|
||||||
|
|
||||||
var vendor = Object.keys(require('./package.json').dependencies);
|
const vendor = Object.keys(require('./package.json').dependencies);
|
||||||
|
|
||||||
const rootPath = path.resolve('./src');
|
const rootPath = path.resolve('./src');
|
||||||
|
|
||||||
@ -39,16 +39,8 @@ if (isTest) {
|
|||||||
|
|
||||||
const CSS_CLASS_TEMPLATE = isProduction ? '[hash:base64:5]' : '[path][name]-[local]';
|
const CSS_CLASS_TEMPLATE = isProduction ? '[hash:base64:5]' : '[path][name]-[local]';
|
||||||
|
|
||||||
var config;
|
|
||||||
try {
|
|
||||||
config = require('./config/dev.json');
|
|
||||||
} catch (err) {
|
|
||||||
console.error('\n\n===\nPlease create dev.json config under ./config based on template.dev.json\n===\n\n');
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
const fileCache = {};
|
const fileCache = {};
|
||||||
|
|
||||||
|
|
||||||
const cssLoaderQuery = {
|
const cssLoaderQuery = {
|
||||||
modules: true,
|
modules: true,
|
||||||
importLoaders: 2,
|
importLoaders: 2,
|
||||||
@ -99,22 +91,6 @@ var webpackConfig = {
|
|||||||
'react/addons': true
|
'react/addons': true
|
||||||
} : {},
|
} : {},
|
||||||
|
|
||||||
devServer: {
|
|
||||||
host: 'localhost',
|
|
||||||
port: 8080,
|
|
||||||
proxy: {
|
|
||||||
'/api*': {
|
|
||||||
headers: {
|
|
||||||
host: config.apiHost.replace(/https?:|\//g, '')
|
|
||||||
},
|
|
||||||
target: config.apiHost
|
|
||||||
}
|
|
||||||
},
|
|
||||||
hot: true,
|
|
||||||
inline: true,
|
|
||||||
historyApiFallback: true
|
|
||||||
},
|
|
||||||
|
|
||||||
devtool: isTest ? 'inline-source-map' : 'eval',
|
devtool: isTest ? 'inline-source-map' : 'eval',
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
@ -238,13 +214,6 @@ var webpackConfig = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isDockerized) {
|
|
||||||
webpackConfig.watchOptions = {
|
|
||||||
poll: 2000
|
|
||||||
};
|
|
||||||
webpackConfig.devServer.host = '0.0.0.0';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isProduction) {
|
if (isProduction) {
|
||||||
webpackConfig.module.loaders.forEach((loader) => {
|
webpackConfig.module.loaders.forEach((loader) => {
|
||||||
if (loader.extractInProduction) {
|
if (loader.extractInProduction) {
|
||||||
@ -268,10 +237,41 @@ if (isProduction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isProduction && !isTest) {
|
if (!isProduction && !isTest) {
|
||||||
|
var config;
|
||||||
|
try {
|
||||||
|
config = require('./config/dev.json');
|
||||||
|
} catch (err) {
|
||||||
|
console.error('\n\n===\nPlease create dev.json config under ./config based on template.dev.json\n===\n\n');
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
webpackConfig.plugins.push(
|
webpackConfig.plugins.push(
|
||||||
new webpack.HotModuleReplacementPlugin(),
|
new webpack.HotModuleReplacementPlugin(),
|
||||||
new webpack.NoErrorsPlugin()
|
new webpack.NoErrorsPlugin()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
webpackConfig.devServer = {
|
||||||
|
host: 'localhost',
|
||||||
|
port: 8080,
|
||||||
|
proxy: {
|
||||||
|
'/api*': {
|
||||||
|
headers: {
|
||||||
|
host: config.apiHost.replace(/https?:|\//g, '')
|
||||||
|
},
|
||||||
|
target: config.apiHost
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hot: true,
|
||||||
|
inline: true,
|
||||||
|
historyApiFallback: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDockerized) {
|
||||||
|
webpackConfig.watchOptions = {
|
||||||
|
poll: 2000
|
||||||
|
};
|
||||||
|
webpackConfig.devServer.host = '0.0.0.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = webpackConfig;
|
module.exports = webpackConfig;
|
||||||
|
Loading…
Reference in New Issue
Block a user