forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request react-bootstrap#691 from AlexKVal/wpCnf
Get under control webpack config files.
- Loading branch information
Showing
14 changed files
with
121 additions
and
281 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]' } | ||
] | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
}); |
Oops, something went wrong.