-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get under control webpack config files. #691
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be in the object declation above as:
devtool: argv.optimizeMinimize ? 'source-map' : undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This came up before, but I also like
eval-source-map
- lets you see the original ES6 code, and is a lot faster when running in "watch" mode than normal source maps. I think we saw that it didn't properly map traceback lines in some cases, though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was specifically in failure stack traces when running tests in karma. I didn't try the browser though. Either way the
webpack/test.config
would override with what's needed there: https://github.com/react-bootstrap/react-bootstrap/pull/691/files#diff-0a73b4c419b2170092ad0f940a3bdc83R9There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change
devtool: 'eval'
for testsinto
devtool: 'eval-source-map'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devtool
for tests needs to beeval
or else failure stack traces don't work. @taion Is proposing that this devtool should beeval-source-map
and I'm inclined to agree.