From 18ac375962e2555a76feb7963de9f5d28441f4fc Mon Sep 17 00:00:00 2001 From: Levi Thomason Date: Tue, 9 Aug 2016 11:46:37 -0700 Subject: [PATCH] refactor(build): flatten /config and /build --- .gitignore | 5 ----- config/_default.js => config.js | 12 ++++++------ config/development.js | 5 ----- config/index.js | 6 ------ config/production.js | 11 ----------- config/staging.js | 6 ------ config/test.js | 4 ---- docs/app/Components/Sidebar/Sidebar.js | 2 +- docs/app/index.ejs | 6 ++++-- gulp/tasks/dll.js | 2 +- gulp/tasks/docs.js | 2 +- gulp/tasks/serve.js | 2 +- build/karma.conf.babel.js => karma.conf.js | 2 +- package.json | 2 +- build/webpack.config.js => webpack.config.js | 2 +- build/webpack.dll.js => webpack.dll.js | 2 +- 16 files changed, 18 insertions(+), 53 deletions(-) rename config/_default.js => config.js (91%) delete mode 100644 config/development.js delete mode 100644 config/index.js delete mode 100644 config/production.js delete mode 100644 config/staging.js delete mode 100644 config/test.js rename build/karma.conf.babel.js => karma.conf.js (98%) rename build/webpack.config.js => webpack.config.js (99%) rename build/webpack.dll.js => webpack.dll.js (97%) diff --git a/.gitignore b/.gitignore index dd8c060459..aa033fc172 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,3 @@ -# HEADS UP! -# -# 'npm run clean' runs rm -rf on all lines in this file. -# - npm-debug.log* node_modules/ bower_components/ diff --git a/config/_default.js b/config.js similarity index 91% rename from config/_default.js rename to config.js index ec5bf2b6d5..d22c734e65 100644 --- a/config/_default.js +++ b/config.js @@ -8,7 +8,7 @@ const __DEV__ = env === 'development' const __STAGING__ = env === 'staging' const __TEST__ = env === 'test' const __PROD__ = env === 'production' -const __BASE__ = '/' +const __BASE__ = __PROD__ ? '/stardust' : '' let config = { env, @@ -16,7 +16,7 @@ let config = { // ---------------------------------- // Project Structure // ---------------------------------- - path_base: path.resolve(__dirname, '../'), + path_base: __dirname, dir_src: 'src', dir_dist: 'dist', dir_docs_root: 'docs', @@ -52,14 +52,14 @@ config = Object.assign({}, config, { // ---------------------------------- // Compiler Configuration // ---------------------------------- - compiler_devtool: false, - compiler_hash_type: 'hash', + compiler_devtool: __DEV__ && 'eval-cheap-module-source-map' || __STAGING__ && 'source-map', + compiler_hash_type: __PROD__ ? 'chunkhash' : 'hash', compiler_inline_manifest: false, - compiler_fail_on_warning: false, + compiler_fail_on_warning: __TEST__ || __PROD__, compiler_lint: argv.lint !== false, compiler_quiet: false, compiler_output_path: paths.base(config.dir_docs_dist), - compiler_public_path: __BASE__, + compiler_public_path: __BASE__ || '/', compiler_vendor: [ 'bluebird', 'classnames', diff --git a/config/development.js b/config/development.js deleted file mode 100644 index 626d0009f4..0000000000 --- a/config/development.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = (config) => { - return { - compiler_devtool: 'eval-cheap-module-source-map', - } -} diff --git a/config/index.js b/config/index.js deleted file mode 100644 index 34a20f2b66..0000000000 --- a/config/index.js +++ /dev/null @@ -1,6 +0,0 @@ -const base = require('./_default') - -const envConfig = require(`./${base.env}`)(base) - - -module.exports = Object.assign({}, base, envConfig) diff --git a/config/production.js b/config/production.js deleted file mode 100644 index 2127031acd..0000000000 --- a/config/production.js +++ /dev/null @@ -1,11 +0,0 @@ -const __BASE__ = '/stardust/' - -module.exports = (config) => ({ - compiler_fail_on_warning: true, - compiler_hash_type: 'chunkhash', - compiler_devtool: false, - compiler_public_path: __BASE__, - compiler_globals: Object.assign({}, config.compiler_globals, { - __BASE__: JSON.stringify(__BASE__), - }), -}) diff --git a/config/staging.js b/config/staging.js deleted file mode 100644 index 6165161ff2..0000000000 --- a/config/staging.js +++ /dev/null @@ -1,6 +0,0 @@ -const config = require('./production') - -// Enable source-maps in staging -config.compiler_devtool = 'source-map' - -module.exports = config diff --git a/config/test.js b/config/test.js deleted file mode 100644 index f8f7807693..0000000000 --- a/config/test.js +++ /dev/null @@ -1,4 +0,0 @@ -// Just use the production configuration -const production = require('./production') - -module.exports = production diff --git a/docs/app/Components/Sidebar/Sidebar.js b/docs/app/Components/Sidebar/Sidebar.js index 4f439af897..d2f32a06c8 100644 --- a/docs/app/Components/Sidebar/Sidebar.js +++ b/docs/app/Components/Sidebar/Sidebar.js @@ -47,7 +47,7 @@ export default class Sidebar extends Component { return (
- + UI-React Docs
diff --git a/docs/app/index.ejs b/docs/app/index.ejs index d959ba91fa..307f6513e4 100644 --- a/docs/app/index.ejs +++ b/docs/app/index.ejs @@ -2,8 +2,10 @@ - - + <% if (htmlWebpackPlugin.options.baseHref) { %> + + <% } %> + diff --git a/gulp/tasks/dll.js b/gulp/tasks/dll.js index 027d94aabe..c4c8e5cada 100644 --- a/gulp/tasks/dll.js +++ b/gulp/tasks/dll.js @@ -8,7 +8,7 @@ const g = loadPlugins() const { log, PluginError } = g.util task('dll', (cb) => { - const webpackDLLConfig = require('../../build/webpack.dll') + const webpackDLLConfig = require('../../webpack.dll') const compiler = webpack(webpackDLLConfig) compiler.run((err, stats) => { diff --git a/gulp/tasks/docs.js b/gulp/tasks/docs.js index 0fa8ba6b5b..eb541fd48d 100644 --- a/gulp/tasks/docs.js +++ b/gulp/tasks/docs.js @@ -31,7 +31,7 @@ task('generate-docs-json', () => { }) task('webpack-docs', (cb) => { - const webpackConfig = require('../../build/webpack.config') + const webpackConfig = require('../../webpack.config') const compiler = webpack(webpackConfig) compiler.run((err, stats) => { diff --git a/gulp/tasks/serve.js b/gulp/tasks/serve.js index 98e410d22a..8291b3dabb 100644 --- a/gulp/tasks/serve.js +++ b/gulp/tasks/serve.js @@ -12,7 +12,7 @@ const g = loadPlugins() const { log, colors } = g.util const serve = (cb) => { - const webpackConfig = require('../../build/webpack.config') + const webpackConfig = require('../../webpack.config') const app = express() const compiler = webpack(webpackConfig) diff --git a/build/karma.conf.babel.js b/karma.conf.js similarity index 98% rename from build/karma.conf.babel.js rename to karma.conf.js index 4f245ef3c3..d05f7278c1 100644 --- a/build/karma.conf.babel.js +++ b/karma.conf.js @@ -1,5 +1,5 @@ const { argv } = require('yargs') -const config = require('../config') +const config = require('./config') const webpack = require('webpack') const webpackConfig = require('./webpack.config') diff --git a/package.json b/package.json index 87243c7c17..1ec9d56e11 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "start": "npm run docs", "start:local-modules": "npm run docs -- --local-modules", "pretest": "gulp dll", - "test": "cross-env NODE_ENV=test karma start build/karma.conf.babel.js", + "test": "cross-env NODE_ENV=test karma start", "test:watch": "npm run test --silent -- --watch" }, "repository": { diff --git a/build/webpack.config.js b/webpack.config.js similarity index 99% rename from build/webpack.config.js rename to webpack.config.js index b1ddd7c06b..6d626708e1 100644 --- a/build/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,4 @@ -const config = require('../config') +const config = require('./config') const webpack = require('webpack') const HtmlWebpackPlugin = require('html-webpack-plugin') const _ = require('lodash') diff --git a/build/webpack.dll.js b/webpack.dll.js similarity index 97% rename from build/webpack.dll.js rename to webpack.dll.js index d8f447b087..9af1cfa244 100644 --- a/build/webpack.dll.js +++ b/webpack.dll.js @@ -1,6 +1,6 @@ const webpack = require('webpack') -const config = require('../config') +const config = require('./config') const webpackDllConfig = { module: {} } const { paths } = config