Skip to content

Commit 64a0286

Browse files
authored
Merge pull request #1226 from maxceem/issue-1196
Fix Issue #1196
2 parents c34f03a + 5619e44 commit 64a0286

File tree

16 files changed

+4124
-1532
lines changed

16 files changed

+4124
-1532
lines changed

.babelrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// this babel config is for tests only
2+
// babel config for client side is places inside webpack config
13
{
2-
"presets": ["es2015", "react", "stage-2"]
4+
"presets": ["env", "react", "stage-2"]
35
}

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# ignore dist directory to speed up linting after we build project
2+
dist/*

config/constants/dev.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module.exports = {
2+
API_URL : 'https://api.topcoder-dev.com/v3',
3+
API_URL_V2 : 'https://api.topcoder-dev.com/v2',
4+
WORK_API_URL : 'https://api-work.topcoder-dev.com/v3',
5+
INTERNAL_API_URL : 'https://internal-api.topcoder-dev.com/v3',
6+
ASSET_PREFIX : 'https://s3.amazonaws.com/app.topcoder-dev.com/',
7+
AUTH_API_URL : 'https://api.topcoder-dev.com/v3',
8+
auth0Callback : 'https://api.topcoder-dev.com/pub/callback.html',
9+
auth0Domain : 'topcoder-dev.auth0.com',
10+
clientId : process.env.AUTH0_CLIENT_ID_DEV,
11+
AUTH0_DOMAIN : 'topcoder-dev.auth0.com',
12+
AUTH0_CLIENT_ID : process.env.AUTH0_CLIENT_ID_DEV,
13+
domain : 'topcoder-dev.com',
14+
DOMAIN : 'topcoder-dev.com',
15+
ENV : 'DEV',
16+
17+
NEW_RELIC_APPLICATION_ID: process.env.TRAVIS_BRANCH ? '8957921' : '',
18+
19+
ARENA_URL : '//arena.topcoder-dev.com',
20+
BLOG_LOCATION : 'https://www.topcoder-dev.com/feed/',
21+
COMMUNITY_URL : '//community.topcoder-dev.com',
22+
FORUMS_APP_URL : '//apps.topcoder-dev.com/forums',
23+
HELP_APP_URL : 'help.topcoder-dev.com',
24+
MAIN_URL : 'https://www.topcoder-dev.com',
25+
PHOTO_LINK_LOCATION: 'https://community.topcoder-dev.com',
26+
SWIFT_PROGRAM_URL : 'apple.topcoder-dev.com',
27+
TCO16_URL : 'http://tco16.topcoder-dev.com',
28+
TCO17_URL : 'http://tco17.topcoder-dev.com',
29+
TCO_HOME_URL : 'https://www.topcoder-dev.com/tco',
30+
31+
ACCOUNTS_APP_URL : 'https://accounts.topcoder-dev.com/#!/member',
32+
ACCOUNTS_APP_CONNECTOR_URL : 'https://accounts.topcoder-dev.com/connector.html',
33+
34+
FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY_DEV,
35+
FILE_PICKER_SUBMISSION_CONTAINER_NAME: 'submission-staging-dev',
36+
37+
SALESFORCE_PROJECT_LEAD_LINK: 'https://c.cs18.visual.force.com/apex/ConnectLead?connectProjectId=',
38+
39+
CONNECT_SEGMENT_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n',
40+
PREDIX_PROGRAM_ID : 3448,
41+
IBM_COGNITIVE_PROGRAM_ID : 3449,
42+
HEAP_ANALYTICS_APP_ID : '4153837120'
43+
}

config/constants/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = (() => {
2+
const branch = process.env.CIRCLE_BRANCH || 'dev'
3+
4+
// for security reason don't let to require any arbitrary file defined in process.env
5+
if (['dev', 'master', 'qa'].indexOf(branch) < 0) {
6+
throw Error('Unsupported CIRCLE_BRANCH value.')
7+
}
8+
9+
return require('./' + branch)
10+
})()

config/constants/master.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module.exports = {
2+
API_URL : 'https://api.topcoder.com/v3',
3+
API_URL_V2 : 'https://api.topcoder.com/v2',
4+
WORK_API_URL : 'https://api-work.topcoder.com/v3',
5+
INTERNAL_API_URL : 'https://internal-api.topcoder.com/v3',
6+
ASSET_PREFIX : 'https://s3.amazonaws.com/app.topcoder.com/',
7+
AUTH_API_URL : 'https://api.topcoder.com/v3',
8+
auth0Callback : 'https://api.topcoder.com/pub/callback.html',
9+
auth0Domain : 'topcoder.auth0.com',
10+
clientId : process.env.AUTH0_CLIENT_ID_PROD,
11+
AUTH0_DOMAIN : 'topcoder.auth0.com',
12+
AUTH0_CLIENT_ID : process.env.AUTH0_CLIENT_ID_PROD,
13+
domain : 'topcoder.com',
14+
DOMAIN : 'topcoder.com',
15+
ENV : 'PROD',
16+
NODE_ENV : 'production',
17+
18+
NEW_RELIC_APPLICATION_ID: process.env.TRAVIS_BRANCH ? '11352758' : '',
19+
20+
ARENA_URL : '//arena.topcoder.com',
21+
BLOG_LOCATION : 'https://www.topcoder.com/feed/',
22+
COMMUNITY_URL : '//community.topcoder.com',
23+
FORUMS_APP_URL : '//apps.topcoder.com/forums',
24+
HELP_APP_URL : 'help.topcoder.com',
25+
MAIN_URL : 'https://www.topcoder.com',
26+
PHOTO_LINK_LOCATION: 'https://community.topcoder.com',
27+
SWIFT_PROGRAM_URL : 'apple.topcoder.com',
28+
TCO16_URL : 'http://tco16.topcoder.com',
29+
TCO17_URL : 'http://tco17.topcoder.com',
30+
TCO_HOME_URL : 'https://www.topcoder.com/tco',
31+
32+
ACCOUNTS_APP_URL : 'https://accounts.topcoder.com/#!/member',
33+
ACCOUNTS_APP_CONNECTOR_URL : 'https://accounts.topcoder.com/connector.html',
34+
35+
FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY_PROD,
36+
FILE_PICKER_SUBMISSION_CONTAINER_NAME: 'submission-staging-prod',
37+
38+
SALESFORCE_PROJECT_LEAD_LINK: 'https://topcoder.my.salesforce.com/apex/ConnectLead?connectProjectId=',
39+
CONNECT_SEGMENT_KEY: 'ajP6cQ5SN2EMUWoWTOLROVnAHsOlsDCn',
40+
PREDIX_PROGRAM_ID : 3448,
41+
IBM_COGNITIVE_PROGRAM_ID : 3449,
42+
HEAP_ANALYTICS_APP_ID : '638908330'
43+
}

config/constants/qa.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
module.exports = {
2+
API_URL : 'https://api.topcoder-qa.com/v3',
3+
API_URL_V2 : 'https://api.topcoder-qa.com/v2',
4+
WORK_API_URL : 'https://api-work.topcoder-qa.com/v3',
5+
INTERNAL_API_URL : 'https://internal-api.topcoder-qa.com/v3',
6+
ASSET_PREFIX : 'https://s3.amazonaws.com/app.topcoder-qa.com/',
7+
AUTH_API_URL : 'https://api.topcoder-qa.com/v3',
8+
auth0Callback : 'https://api.topcoder-qa.com/pub/callback.html',
9+
auth0Domain : 'topcoder-qa.auth0.com',
10+
clientId : process.env.AUTH0_CLIENT_ID_QA,
11+
AUTH0_DOMAIN : 'topcoder-qa.auth0.com',
12+
AUTH0_CLIENT_ID : process.env.AUTH0_CLIENT_ID_QA,
13+
domain : 'topcoder-qa.com',
14+
DOMAIN : 'topcoder-qa.com',
15+
ENV : 'QA',
16+
17+
NEW_RELIC_APPLICATION_ID: process.env.TRAVIS_BRANCH ? '11199233' : '',
18+
19+
ARENA_URL : '//arena.topcoder-qa.com',
20+
BLOG_LOCATION : 'https://www.topcoder-qa.com/feed/',
21+
COMMUNITY_URL : '//community.topcoder-qa.com',
22+
FORUMS_APP_URL : '//apps.topcoder-qa.com/forums',
23+
HELP_APP_URL : 'help.topcoder-qa.com',
24+
MAIN_URL : 'https://www.topcoder-qa.com',
25+
PHOTO_LINK_LOCATION: 'https://community.topcoder-qa.com',
26+
SWIFT_PROGRAM_URL : 'apple.topcoder-qa.com',
27+
TCO16_URL : 'http://tco16.topcoder-qa.com',
28+
TCO17_URL : 'http://tco17.topcoder-qa.com',
29+
TCO_HOME_URL : 'https://www.topcoder-dev.com/tco',
30+
31+
ACCOUNTS_APP_URL : 'https://accounts.topcoder-qa.com/#!/member',
32+
ACCOUNTS_APP_CONNECTOR_URL : 'https://accounts.topcoder-qa.com/connector.html',
33+
34+
FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY_QA,
35+
FILE_PICKER_SUBMISSION_CONTAINER_NAME: 'submission-staging-qa',
36+
37+
SALESFORCE_PROJECT_LEAD_LINK: 'https://c.cs18.visual.force.com/apex/ConnectLead?connectProjectId=',
38+
CONNECT_SEGMENT_KEY: '',
39+
PREDIX_PROGRAM_ID : 3448,
40+
IBM_COGNITIVE_PROGRAM_ID : 3449,
41+
HEAP_ANALYTICS_APP_ID : '4153837120'
42+
}

config/webpack/default.js

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
'use strict'
2+
3+
const _ = require('lodash')
4+
const path = require('path')
5+
const webpack = require('webpack')
6+
const FaviconsWebpackPlugin = require('favicons-webpack-plugin')
7+
const ExtractCssChunks = require('extract-css-chunks-webpack-plugin')
8+
const HtmlWebpackPlugin = require('html-webpack-plugin')
9+
10+
const constants = require('../constants')
11+
12+
const dirname = path.resolve(__dirname, '../..')
13+
14+
module.exports = {
15+
context: dirname,
16+
17+
entry: [
18+
'./src/styles/main.scss',
19+
'./src/index'
20+
],
21+
22+
output: {
23+
path : path.join(dirname, '/dist'),
24+
filename : '[name].[hash].js',
25+
chunkFilename : '[name].[hash].js'
26+
},
27+
28+
module: {
29+
rules: [{
30+
test: /\.(js|jsx)$/,
31+
loader: 'babel-loader',
32+
exclude: /node_modules\/(?!appirio-tech.*|topcoder|tc-)/,
33+
options: {
34+
babelrc: false,
35+
presets: [ 'env', 'react', 'stage-2' ],
36+
plugins: [ 'lodash' ]
37+
}
38+
}, {
39+
test: /\.(coffee|litcoffee|cjsx)$/,
40+
use: [
41+
{
42+
loader: 'babel-loader',
43+
options: {
44+
babelrc: false,
45+
presets: [ 'env', 'react', 'stage-2' ],
46+
plugins: [ 'lodash' ]
47+
}
48+
},
49+
'coffee-loader',
50+
'cjsx-loader'
51+
]
52+
}, {
53+
test: /\.json$/,
54+
loader: 'json-loader'
55+
}, {
56+
/* We have to support css loading for third-party plugins,
57+
* we are not supposed to use css files inside the project. */
58+
test: /\.css$/,
59+
use: ExtractCssChunks.extract({
60+
fallback: 'style-loader',
61+
use: ['css-loader']
62+
})
63+
}, {
64+
// ASSET LOADER
65+
// Copy png, jpg, jpeg, gif, svg, woff, woff2, ttf, eot files to output
66+
// Rename the file using the asset hash
67+
// Pass along the updated reference to your code
68+
// You can add here any file extension you want to get copied to your output
69+
test: /\.(png|jpg|jpeg|gif)$/,
70+
loader: 'file-loader'
71+
}, {
72+
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
73+
loader: 'file-loader'
74+
}, {
75+
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
76+
loader: 'file-loader'
77+
}]
78+
79+
},
80+
81+
resolve: {
82+
extensions: [
83+
'.js',
84+
'.jsx',
85+
'.json',
86+
'.coffee',
87+
'.scss',
88+
'.svg',
89+
'.png',
90+
'.gif',
91+
'.jpg',
92+
'.cjsx'
93+
]
94+
},
95+
96+
plugins: [
97+
new webpack.DefinePlugin({
98+
'process.env': _.mapValues(constants, (value) => JSON.stringify(value))
99+
}),
100+
new FaviconsWebpackPlugin({
101+
logo: './src/favicon.png',
102+
// disable cache, otherwise when there is a dist folder with icons
103+
// icons don't wanna be generated in memory using webpack-dev-server
104+
persistentCache: false
105+
}),
106+
new HtmlWebpackPlugin({
107+
template: path.join(dirname, '/src/index.html'),
108+
inject: 'body'
109+
}),
110+
// Only emit files when there are no errors
111+
new webpack.NoEmitOnErrorsPlugin(),
112+
new ExtractCssChunks({
113+
filename: '[name].css',
114+
justExtract: true
115+
})
116+
]
117+
}

config/webpack/development.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
const path = require('path')
2+
const webpack = require('webpack')
3+
const webpackMerge = require('webpack-merge')
4+
5+
const defaultConfig = require('./default')
6+
7+
const dirname = path.resolve(__dirname, '../..')
8+
9+
module.exports = webpackMerge(defaultConfig, {
10+
entry: [
11+
'react-hot-loader/patch'
12+
],
13+
14+
devtool: 'eval',
15+
16+
module: {
17+
rules: [{
18+
test: /\.(js|jsx)$/,
19+
loader: 'babel-loader',
20+
exclude: /node_modules\/(?!appirio-tech.*|topcoder|tc-)/,
21+
options: {
22+
babelrc: false,
23+
presets: [ ['env', { modules: false }], 'react', 'stage-2' ],
24+
plugins: [
25+
'lodash',
26+
// add react hot reloader
27+
'react-hot-loader/babel'
28+
]
29+
}
30+
}, {
31+
test: /\.scss$/,
32+
use: [
33+
'style-loader',
34+
{
35+
loader: 'css-loader',
36+
options: {
37+
sourceMap: true
38+
}
39+
},
40+
'resolve-url-loader',
41+
{
42+
loader: 'sass-loader',
43+
options: {
44+
sourceMap: true,
45+
includePaths: [
46+
path.join(dirname, '/node_modules/bourbon/app/assets/stylesheets'),
47+
path.join(dirname, '/node_modules/tc-ui/src/styles')
48+
]
49+
}
50+
}
51+
]
52+
}]
53+
},
54+
55+
plugins: [
56+
// don't add HotModuleReplacementPlugin, because run webpack-dev-server with --hot param
57+
// otherwise this plugin will be added twice and cause bugs
58+
// new webpack.HotModuleReplacementPlugin(),
59+
60+
new webpack.NamedModulesPlugin()
61+
]
62+
})

config/webpack/production.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const path = require('path')
2+
const webpack = require('webpack')
3+
const webpackMerge = require('webpack-merge')
4+
const CompressionPlugin = require('compression-webpack-plugin')
5+
const ExtractCssChunks = require('extract-css-chunks-webpack-plugin')
6+
7+
const defaultConfig = require('./default')
8+
9+
const dirname = path.resolve(__dirname, '../..')
10+
11+
module.exports = webpackMerge(defaultConfig, {
12+
devtool: 'source-map',
13+
14+
module: {
15+
rules: [{
16+
test: /\.scss$/,
17+
use: ExtractCssChunks.extract({
18+
fallback: 'style-loader',
19+
use: [{
20+
loader: 'css-loader',
21+
options: {
22+
sourceMap: true
23+
}
24+
},
25+
'resolve-url-loader',
26+
{
27+
loader: 'sass-loader',
28+
options: {
29+
sourceMap: true,
30+
includePaths: [
31+
path.join(dirname, '/node_modules/bourbon/app/assets/stylesheets'),
32+
path.join(dirname, '/node_modules/tc-ui/src/styles')
33+
]
34+
}
35+
}]
36+
})
37+
}]
38+
},
39+
40+
plugins: [
41+
// Do not include any .mock.js files if this is a build
42+
new webpack.IgnorePlugin(/\.mock\.js/),
43+
new webpack.optimize.UglifyJsPlugin({
44+
mangle: true
45+
}),
46+
new CompressionPlugin({
47+
asset: '[file]',
48+
algorithm: 'gzip',
49+
regExp: /\.js$|\.css$/,
50+
threshold: 10240,
51+
minRatio: 0.8
52+
})
53+
]
54+
})

0 commit comments

Comments
 (0)