Skip to content

Commit

Permalink
fix(bundle): don't include sourcemap in bundle (#289)
Browse files Browse the repository at this point in the history
* feat(bundle): better minification

* fix(minification): fixed minification in dev mode

* test: updated snapshots
  • Loading branch information
jukben authored and satya164 committed Nov 23, 2017
1 parent da0f752 commit ef9690f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports[`creates config from defaults (configs) 1`] = `
Array [
Object {
"context": "<<REPLACED>>/utils/__tests__/fixtures",
"devtool": "eval-source-map",
"entry": Array [
"<<REPLACED>>/utils/polyfillEnvironment.js",
"./file.js",
Expand Down Expand Up @@ -85,23 +84,17 @@ Array [
},
},
},
SourceMapDevToolPlugin {
"fallbackModuleFilenameTemplate": "webpack:///[resourcePath]?[hash]",
"moduleFilenameTemplate": "webpack:///[resourcePath]",
"options": Object {
"filename": "[file].map",
"test": /\\\\\\.\\(js\\|css\\|bundle\\)\\(\\$\\|\\\\\\?\\)/i,
},
"sourceMapFilename": "[file].map",
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
HotModuleReplacementPlugin {
"fullBuildTimeout": 200,
"multiStep": undefined,
"options": Object {},
"requestTimeout": 10000,
},
EvalSourceMapDevToolPlugin {
"options": Object {
"module": true,
},
},
NamedModulesPlugin {
"options": Object {},
},
Expand Down Expand Up @@ -130,7 +123,6 @@ Array [
},
Object {
"context": "<<REPLACED>>/utils/__tests__/fixtures",
"devtool": "eval-source-map",
"entry": Array [
"<<REPLACED>>/utils/polyfillEnvironment.js",
"./file.js",
Expand Down Expand Up @@ -211,23 +203,17 @@ Array [
},
},
},
SourceMapDevToolPlugin {
"fallbackModuleFilenameTemplate": "webpack:///[resourcePath]?[hash]",
"moduleFilenameTemplate": "webpack:///[resourcePath]",
"options": Object {
"filename": "[file].map",
"test": /\\\\\\.\\(js\\|css\\|bundle\\)\\(\\$\\|\\\\\\?\\)/i,
},
"sourceMapFilename": "[file].map",
"sourceMappingURLComment": "
//# sourceMappingURL=[url]",
},
HotModuleReplacementPlugin {
"fullBuildTimeout": 200,
"multiStep": undefined,
"options": Object {},
"requestTimeout": 10000,
},
EvalSourceMapDevToolPlugin {
"options": Object {
"module": true,
},
},
NamedModulesPlugin {
"options": Object {},
},
Expand Down Expand Up @@ -268,7 +254,6 @@ exports[`merges existing config 1`] = `
Array [
Object {
"context": "<<REPLACED>>/utils/__tests__/fixtures",
"devtool": "eval-source-map",
"entry": Array [
"<<REPLACED>>/utils/polyfillEnvironment.js",
"/some/file.js",
Expand All @@ -294,7 +279,6 @@ Array [
},
Object {
"context": "<<REPLACED>>/utils/__tests__/fixtures",
"devtool": "eval-source-map",
"entry": Array [
"<<REPLACED>>/utils/polyfillEnvironment.js",
"/some/file.js",
Expand Down
32 changes: 19 additions & 13 deletions src/utils/makeReactNativeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const getDefaultConfig = ({
const platformProgressBar = haulProgressBar(platform);
return {
context: root,
devtool: bundle ? 'source-map' : 'eval-source-map',
entry: [],
output: {
path: path.join(root, 'dist'),
Expand Down Expand Up @@ -128,33 +127,40 @@ const getDefaultConfig = ({
minimize: !!minify,
debug: dev,
}),
/**
* By default, sourcemaps are only generated with *.js files
* We need to use the plugin to configure *.bundle to emit sourcemap
*/
new webpack.SourceMapDevToolPlugin({
test: /\.(js|css|bundle)($|\?)/i,
filename: '[file].map',
}),
]
.concat(
dev
? [
new webpack.HotModuleReplacementPlugin(),
new webpack.EvalSourceMapDevToolPlugin({
module: true,
}),
new webpack.NamedModulesPlugin(),
]
: new webpack.optimize.ModuleConcatenationPlugin()
: [
/**
* By default, sourcemaps are only generated with *.js files
* We need to use the plugin to configure *.bundle (Android, iOS - development)
* and *.jsbundle (iOS - production) to emit sourcemap
*/
new webpack.SourceMapDevToolPlugin({
test: /\.(js|css|(js)?bundle)($|\?)/i,
filename: '[file].map',
}),
new webpack.optimize.ModuleConcatenationPlugin(),
]
)
.concat(
minify
? [
new webpack.optimize.UglifyJsPlugin({
/**
* By default, uglify only minifies *.js files
* We need to use the plugin to configutr *.bundle to get minified
* Also disable IE8 support as we don't need it'
* We need to use the plugin to configure *.bundle (Android, iOS - development)
* and *.jsbundle (iOS - production) to get minified.
* Also disable IE8 support as we don't need it.
*/
test: /\.(js|bundle)($|\?)/i,
test: /\.(js|(js)?bundle)($|\?)/i,
sourceMap: true,
compress: {
screw_ie8: true,
Expand Down

0 comments on commit ef9690f

Please sign in to comment.