Reorganize karma and webpack configs

This commit is contained in:
Nicolas Gallagher
2016-03-10 08:52:37 -08:00
parent 83e4c68461
commit c589d79035
6 changed files with 17 additions and 27 deletions
-11
View File
@@ -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')
}
-1
View File
@@ -70,7 +70,6 @@ module.exports = {
// ... // ...
plugins: [ plugins: [
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'Platform.OS': 'web',
'process.env.NODE_ENV': JSON.stringify('production') 'process.env.NODE_ENV': JSON.stringify('production')
}) })
} }
@@ -1,13 +1,14 @@
const constants = require('./constants')
const path = require('path') const path = require('path')
const webpack = require('webpack') const webpack = require('webpack')
const EXAMPLES_DIRECTORY = __dirname
module.exports = { module.exports = {
devServer: { devServer: {
contentBase: constants.EXAMPLES_DIRECTORY contentBase: EXAMPLES_DIRECTORY
}, },
entry: { entry: {
example: constants.EXAMPLES_DIRECTORY example: EXAMPLES_DIRECTORY
}, },
module: { module: {
loaders: [ loaders: [
@@ -20,7 +21,7 @@ module.exports = {
] ]
}, },
output: { output: {
filename: 'examples.js' filename: 'bundle.js'
}, },
plugins: [ plugins: [
new webpack.DefinePlugin({ new webpack.DefinePlugin({
+4 -4
View File
@@ -1,9 +1,9 @@
var constants = require('./constants')
var webpack = require('webpack') var webpack = require('webpack')
var testEntry = 'tests.webpack.js'
module.exports = function (config) { module.exports = function (config) {
config.set({ config.set({
basePath: constants.ROOT_DIRECTORY,
browsers: process.env.TRAVIS ? [ 'Firefox' ] : [ 'Chrome' ], browsers: process.env.TRAVIS ? [ 'Firefox' ] : [ 'Chrome' ],
browserNoActivityTimeout: 60000, browserNoActivityTimeout: 60000,
client: { client: {
@@ -12,7 +12,7 @@ module.exports = function (config) {
useIframe: true useIframe: true
}, },
files: [ files: [
constants.TEST_ENTRY testEntry
], ],
frameworks: [ 'mocha' ], frameworks: [ 'mocha' ],
plugins: [ plugins: [
@@ -24,7 +24,7 @@ module.exports = function (config) {
'karma-webpack' 'karma-webpack'
], ],
preprocessors: { preprocessors: {
[constants.TEST_ENTRY]: [ 'webpack', 'sourcemap' ] [testEntry]: [ 'webpack', 'sourcemap' ]
}, },
reporters: process.env.TRAVIS ? [ 'dots' ] : [ 'spec' ], reporters: process.env.TRAVIS ? [ 'dots' ] : [ 'spec' ],
singleRun: true, singleRun: true,
+4 -4
View File
@@ -8,11 +8,11 @@
], ],
"scripts": { "scripts": {
"build": "rm -rf ./dist && mkdir dist && babel src -d dist --ignore **/__tests__,src/modules/specHelpers", "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", "build:umd": "webpack --config webpack.config.js --sort-assets-by --progress",
"examples": "webpack-dev-server --config config/webpack.config.example.js --inline --hot --colors --quiet", "examples": "webpack-dev-server --config examples/webpack.config.js --inline --hot --colors --quiet",
"lint": "eslint config src", "lint": "eslint src",
"prepublish": "npm run build && npm run build:umd", "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" "test:watch": "npm run test -- --no-single-run"
}, },
"dependencies": { "dependencies": {
@@ -1,9 +1,10 @@
var constants = require('./constants')
var webpack = require('webpack') var webpack = require('webpack')
const DIST_DIRECTORY = './dist'
module.exports = { module.exports = {
entry: { entry: {
main: constants.DIST_DIRECTORY main: DIST_DIRECTORY
}, },
externals: [{ externals: [{
'react': true, 'react': true,
@@ -14,7 +15,7 @@ module.exports = {
filename: 'react-native-web.js', filename: 'react-native-web.js',
library: 'ReactNativeWeb', library: 'ReactNativeWeb',
libraryTarget: 'umd', libraryTarget: 'umd',
path: constants.DIST_DIRECTORY path: DIST_DIRECTORY
}, },
plugins: [ plugins: [
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),