Created
February 28, 2018 02:57
-
-
Save johnywith1n/8ddf42309f3bf4fa4a4b3537c3d956ba to your computer and use it in GitHub Desktop.
Example config for webpack not generating sourcemaps
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
const path = require('path'); | |
const webpack = require('webpack'); | |
const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); | |
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); | |
const ExtractTextPlugin = require("extract-text-webpack-plugin"); | |
module.exports = { | |
mode: 'production', | |
entry: { | |
'app': [ | |
'./static/js/react/app/app.js' | |
] | |
}, | |
output: { | |
path: __dirname + '/static/dist', | |
filename: '[name].bundle.js', | |
sourceMapFilename: '[file].map', | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
loader: 'babel-loader', | |
options: { | |
cacheDirectory: true | |
}, | |
include: [ | |
path.resolve(__dirname, 'static/js/react') | |
], | |
exclude: path.resolve(__dirname, 'node_modules') | |
}, | |
{ | |
test: /\.css$/, | |
use: ExtractTextPlugin.extract({ | |
fallback: "style-loader", | |
use: [ | |
{ | |
loader: 'css-loader', | |
options: { | |
modules: true, | |
localIdentName: '[local]_[hash:base64:5]', | |
sourceMap: false, | |
} | |
} | |
] | |
}), | |
include: [ | |
path.resolve(__dirname, 'static/js/react'), | |
], | |
exclude: path.resolve(__dirname, 'node_modules') | |
}, | |
{ | |
test: /\.css$/, | |
use: ExtractTextPlugin.extract({ | |
fallback: "style-loader", | |
use: [ | |
{ | |
loader: 'css-loader', | |
options: { | |
sourceMap: false, | |
} | |
} | |
] | |
}), | |
include: [ | |
path.resolve(__dirname, 'node_modules/bootstrap'), | |
], | |
exclude: /node_modules\/(?!(bootstrap)\/).*/ | |
}, | |
] | |
}, | |
plugins: [ | |
new webpack.ProvidePlugin({ | |
$: 'jquery', | |
jQuery: 'jquery', | |
'window.jQuery': 'jquery', | |
Popper: ['popper.js', 'default'], | |
// In case you imported bootstrap plugins individually, you must also require them here: | |
// Util: "exports-loader?Util!bootstrap/js/dist/util", | |
// Dropdown: "exports-loader?Dropdown!bootstrap/js/dist/dropdown", | |
}), | |
new ExtractTextPlugin("[name]-styles.css"), | |
new UglifyJSPlugin({ | |
sourceMap: true, | |
parallel: true, | |
cache: true | |
}), | |
new webpack.SourceMapDevToolPlugin({ | |
append: "\n//# sourceMappingURL=http://localhost:8081/static/dist/[url]", | |
filename: '[file].map', | |
exclude: /node_modules\/(?!(bootstrap)\/).*/ | |
}), | |
new HardSourceWebpackPlugin(), | |
], | |
externals: { | |
"jquery": "jQuery", | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment