-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config sourcemap loader (webpack) to remove warnings
- Loading branch information
1 parent
7e19bb7
commit f28f6fc
Showing
3 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -68,3 +68,4 @@ common/autoinstallers/*/.npmrc | |
**/lib-esm/ | ||
**/lib-cjs/ | ||
**/dist/ | ||
lib-browser/ |
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 |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
"dist", | ||
"lib", | ||
"lib-esm", | ||
//"temp" | ||
"lib-browser", | ||
"temp", | ||
"built" | ||
] | ||
} |
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,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 | ||
|
@@ -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: { | ||
|