From c589d79035b29540e0cf4c24e2f9f7eb3ee406cd Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Thu, 10 Mar 2016 08:52:37 -0800 Subject: [PATCH] Reorganize karma and webpack configs --- config/constants.js | 11 ----------- docs/guides/react-native.md | 1 - .../webpack.config.js | 9 +++++---- config/karma.config.js => karma.config.js | 8 ++++---- package.json | 8 ++++---- config/webpack.config.js => webpack.config.js | 7 ++++--- 6 files changed, 17 insertions(+), 27 deletions(-) delete mode 100644 config/constants.js rename config/webpack.config.example.js => examples/webpack.config.js (80%) rename config/karma.config.js => karma.config.js (87%) rename config/webpack.config.js => webpack.config.js (85%) diff --git a/config/constants.js b/config/constants.js deleted file mode 100644 index 8fc353a7..00000000 --- a/config/constants.js +++ /dev/null @@ -1,11 +0,0 @@ -var path = require('path') - -var ROOT = path.join(__dirname, '..') - -module.exports = { - DIST_DIRECTORY: path.join(ROOT, 'dist'), - EXAMPLES_DIRECTORY: path.join(ROOT, 'examples'), - SRC_DIRECTORY: path.join(ROOT, 'src'), - ROOT_DIRECTORY: ROOT, - TEST_ENTRY: path.join(ROOT, 'tests.webpack.js') -} diff --git a/docs/guides/react-native.md b/docs/guides/react-native.md index 9b926405..2227c6ca 100644 --- a/docs/guides/react-native.md +++ b/docs/guides/react-native.md @@ -70,7 +70,6 @@ module.exports = { // ... plugins: [ new webpack.DefinePlugin({ - 'Platform.OS': 'web', 'process.env.NODE_ENV': JSON.stringify('production') }) } diff --git a/config/webpack.config.example.js b/examples/webpack.config.js similarity index 80% rename from config/webpack.config.example.js rename to examples/webpack.config.js index 0679084a..a4da0a30 100644 --- a/config/webpack.config.example.js +++ b/examples/webpack.config.js @@ -1,13 +1,14 @@ -const constants = require('./constants') const path = require('path') const webpack = require('webpack') +const EXAMPLES_DIRECTORY = __dirname + module.exports = { devServer: { - contentBase: constants.EXAMPLES_DIRECTORY + contentBase: EXAMPLES_DIRECTORY }, entry: { - example: constants.EXAMPLES_DIRECTORY + example: EXAMPLES_DIRECTORY }, module: { loaders: [ @@ -20,7 +21,7 @@ module.exports = { ] }, output: { - filename: 'examples.js' + filename: 'bundle.js' }, plugins: [ new webpack.DefinePlugin({ diff --git a/config/karma.config.js b/karma.config.js similarity index 87% rename from config/karma.config.js rename to karma.config.js index a89ba871..0e09094c 100644 --- a/config/karma.config.js +++ b/karma.config.js @@ -1,9 +1,9 @@ -var constants = require('./constants') var webpack = require('webpack') +var testEntry = 'tests.webpack.js' + module.exports = function (config) { config.set({ - basePath: constants.ROOT_DIRECTORY, browsers: process.env.TRAVIS ? [ 'Firefox' ] : [ 'Chrome' ], browserNoActivityTimeout: 60000, client: { @@ -12,7 +12,7 @@ module.exports = function (config) { useIframe: true }, files: [ - constants.TEST_ENTRY + testEntry ], frameworks: [ 'mocha' ], plugins: [ @@ -24,7 +24,7 @@ module.exports = function (config) { 'karma-webpack' ], preprocessors: { - [constants.TEST_ENTRY]: [ 'webpack', 'sourcemap' ] + [testEntry]: [ 'webpack', 'sourcemap' ] }, reporters: process.env.TRAVIS ? [ 'dots' ] : [ 'spec' ], singleRun: true, diff --git a/package.json b/package.json index 42555b5f..118534d3 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,11 @@ ], "scripts": { "build": "rm -rf ./dist && mkdir dist && babel src -d dist --ignore **/__tests__,src/modules/specHelpers", - "build:umd": "webpack --config config/webpack.config.js --sort-assets-by --progress", - "examples": "webpack-dev-server --config config/webpack.config.example.js --inline --hot --colors --quiet", - "lint": "eslint config src", + "build:umd": "webpack --config webpack.config.js --sort-assets-by --progress", + "examples": "webpack-dev-server --config examples/webpack.config.js --inline --hot --colors --quiet", + "lint": "eslint src", "prepublish": "npm run build && npm run build:umd", - "test": "karma start config/karma.config.js", + "test": "karma start karma.config.js", "test:watch": "npm run test -- --no-single-run" }, "dependencies": { diff --git a/config/webpack.config.js b/webpack.config.js similarity index 85% rename from config/webpack.config.js rename to webpack.config.js index 5023e5bb..0c24f7c4 100644 --- a/config/webpack.config.js +++ b/webpack.config.js @@ -1,9 +1,10 @@ -var constants = require('./constants') var webpack = require('webpack') +const DIST_DIRECTORY = './dist' + module.exports = { entry: { - main: constants.DIST_DIRECTORY + main: DIST_DIRECTORY }, externals: [{ 'react': true, @@ -14,7 +15,7 @@ module.exports = { filename: 'react-native-web.js', library: 'ReactNativeWeb', libraryTarget: 'umd', - path: constants.DIST_DIRECTORY + path: DIST_DIRECTORY }, plugins: [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),