Skip to content

Commit

Permalink
config sourcemap loader (webpack) to remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonswearingen committed Sep 23, 2020
1 parent 7e19bb7 commit f28f6fc
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ common/autoinstallers/*/.npmrc
**/lib-esm/
**/lib-cjs/
**/dist/
lib-browser/
4 changes: 3 additions & 1 deletion libraries/xlib/.heft/clean.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"dist",
"lib",
"lib-esm",
//"temp"
"lib-browser",
"temp",
"built"
]
}
52 changes: 49 additions & 3 deletions libraries/xlib/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const config = require("./package.json")

const path = require('path');
/** See here for documentation: https://github.com/jantimon/html-webpack-plugin
* will automatically inject the webpack bundles into this page
Expand Down Expand Up @@ -42,20 +44,64 @@ function createWebpackConfig({ production }) {
{
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader'], //needed to chain sourcemaps. see: https://webpack.js.org/loaders/source-map-loader/
use: [
{
//needed to chain sourcemaps. see: https://webpack.js.org/loaders/source-map-loader/
loader: 'source-map-loader',
options: {

filterSourceMappingUrl: (url, resourcePath) => {
// console.log({ url, resourcePath }) example:
// {
// url: 'index.js.map',
// resourcePath: '/repos/xlib-wsl/common/temp/node_modules/.pnpm/[email protected]/node_modules/https-proxy-agent/dist/index.js'
// }

if (/.*\/node_modules\/.*/.test(resourcePath)) {
return false
}
return true
}

}
}],
},
]
},
// //! stats.warnings doesn't seem to work. see: https://stackoverflow.com/questions/63195843/webpack-module-warning-failed-to-parse-source-map-from-data-url/64035413#64035413
//devServer: {
// stats: {
// //ignore source-map failure warnings: https://webpack.js.org/loaders/source-map-loader/#ignoring-warnings
// //warningsFilter: [/Failed to parse source map/],
// warnings: false
// },
//stats: 'errors-only'
//},
// stats: {
// warnings: false
// },
//stats: 'errors-only',
entry: {
app: path.join(__dirname, 'lib-esm', '_main.js'),

// Put these libraries in a separate vendor bundle
//vendor: ['react', 'react-dom']
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name]_[contenthash].js'
path: path.join(__dirname, 'lib-browser'),
filename: `${config.name}.bundle.js` //'[name]_[contenthash].js'
},
// optimization: {
// //puts external libraries in seperate bundle files. see https://webpack.js.org/guides/code-splitting/#prevent-duplication
// splitChunks: {
// cacheGroups: {
// imports: {
// chunks: 'all',
// // name: (module,chunks,cacheGroupKey),
// }
// }
// }
// },
devtool: production ? undefined : 'source-map',
// // not needed:
// devServer: {
Expand Down

0 comments on commit f28f6fc

Please sign in to comment.