Skip to content

Commit

Permalink
Merge pull request react-bootstrap#691 from AlexKVal/wpCnf
Browse files Browse the repository at this point in the history
Get under control webpack config files.
  • Loading branch information
mtscout6 committed May 20, 2015
2 parents 115412e + 2a1d7f6 commit 1b58489
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 281 deletions.
14 changes: 0 additions & 14 deletions ie8/package.json

This file was deleted.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"docs-build": "babel-node tools/build-cli.js --docs-only",
"docs": "docs/dev-run",
"docs-prod": "npm run docs-build && NODE_ENV=production babel-node docs/server.js",
"docs-prod-unoptimized": "npm run docs-build -- --dev && NODE_ENV=production babel-node docs/server.js",
"ie8": "babel-node ie8/server.js"
"docs-prod-unoptimized": "npm run docs-build -- --dev && NODE_ENV=production babel-node docs/server.js"
},
"main": "lib/index.js",
"directories": {
Expand Down Expand Up @@ -87,4 +86,4 @@
"dependencies": {
"classnames": "^2.0.0"
}
}
}
3 changes: 1 addition & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint no-var: 0 */
require('babel/register');
var config = require('./webpack/webpack.config');
var result = config();
module.exports = result;
module.exports = config;
41 changes: 41 additions & 0 deletions webpack/base.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import webpack from 'webpack';
import yargs from 'yargs';

export const options = yargs
.alias('p', 'optimize-minimize')
.alias('d', 'debug')
.option('port', {
default: '8080',
type: 'string'
})
.argv;

export const jsLoader = 'babel';

const baseConfig = {
entry: undefined,

output: undefined,

externals: undefined,

module: {
loaders: [
{ test: /\.js/, loader: jsLoader, exclude: /node_modules/ }
]
},

plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(options.optimizeMinimize ? 'production' : 'development')
}
})
]
};

if (options.optimizeMinimize) {
baseConfig.devtool = 'source-map';
}

export default baseConfig;
59 changes: 44 additions & 15 deletions webpack/docs.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
import config from './webpack.config';
import yargs from 'yargs';
import _ from 'lodash';
import webpack from 'webpack';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import baseConfig, { options, jsLoader } from './base.config';

const argv = yargs
.alias('p', 'optimize-minimize')
.alias('d', 'debug')
.option('port', {
default: '8080',
type: 'string'
})
.argv;
const webpackDevServerAddress = `http://localhost:${options.port}`;
const cssSourceMap = options.debug ? '?sourceMap' : '';
const reactHot = options.debug ? 'react-hot!' : '';

export default config({
docs: true,
development: argv.debug,
optimize: argv.optimizeMinimize,
port: parseInt(argv.port)
const entryFile = './docs/client.js';
const devEntryBundle = [
'webpack/hot/dev-server',
`webpack-dev-server/client?${webpackDevServerAddress}`,
entryFile
];

baseConfig.plugins.push(new ExtractTextPlugin('[name].css'));
if (options.debug) {
baseConfig.plugins.push(new webpack.NoErrorsPlugin());
}

export default _.extend({}, baseConfig, {
entry: {
bundle: options.debug ? devEntryBundle : entryFile
},

output: {
filename: '[name].js',
path: './docs-built/assets',
publicPath: options.debug ? `${webpackDevServerAddress}/assets/` : '/assets/'
},

module: {
noParse: /babel-core\/browser/,
loaders: [
{ test: /\.js/, loader: `${reactHot}${jsLoader}`, exclude: /node_modules|Samples\.js/ },
{ test: /Samples.js/, loader: `${reactHot}transform?brfs!${jsLoader}` },
{ test: /\.css/,
loader: ExtractTextPlugin.extract('style', `css${cssSourceMap}`) },
{ test: /\.less$/,
loader: ExtractTextPlugin.extract('style', `css${cssSourceMap}!less${cssSourceMap}`) },
{ test: /\.json$/, loader: 'json' },
{ test: /\.jpe?g$|\.gif$|\.png|\.ico$/, loader: 'file?name=[name].[ext]' },
{ test: /\.eot$|\.ttf$|\.svg$|\.woff2?$/, loader: 'file?name=[name].[ext]' }
]
}
});
13 changes: 0 additions & 13 deletions webpack/strategies/development.js

This file was deleted.

40 changes: 0 additions & 40 deletions webpack/strategies/docs-development.js

This file was deleted.

55 changes: 0 additions & 55 deletions webpack/strategies/docs.js

This file was deleted.

26 changes: 0 additions & 26 deletions webpack/strategies/ie8.js

This file was deleted.

15 changes: 0 additions & 15 deletions webpack/strategies/index.js

This file was deleted.

17 changes: 0 additions & 17 deletions webpack/strategies/optimize.js

This file was deleted.

18 changes: 0 additions & 18 deletions webpack/strategies/test.js

This file was deleted.

11 changes: 9 additions & 2 deletions webpack/test.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import config from './webpack.config';
import _ from 'lodash';
import baseConfig from './base.config';

export default config({test: true});
export default _.extend({}, baseConfig, {
output: {
pathinfo: true
},

devtool: 'eval'
});
Loading

0 comments on commit 1b58489

Please sign in to comment.