-
Notifications
You must be signed in to change notification settings - Fork 375
fix: Added a build:dev yarn task to PVA Publish to create source maps #4831
Changes from 5 commits
1f9ecc6
6acb8a0
3968f22
7784794
6a1ae6c
a875fb0
79e4dd3
5a0e6f1
e37572e
2d2dafc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,54 +1,66 @@ | ||
| const { resolve } = require('path'); | ||
| const svgToMiniDataURI = require('mini-svg-data-uri'); | ||
|
|
||
| module.exports = [ | ||
| { | ||
| entry: './src/ui/index.tsx', | ||
| mode: 'production', | ||
| output: { | ||
| filename: 'publish-bundle.js', | ||
| path: resolve(__dirname, 'lib', 'ui'), | ||
| }, | ||
| externals: { | ||
| // expect react & react-dom to be available in the extension host iframe | ||
| react: 'React', | ||
| 'react-dom': 'ReactDOM', | ||
| }, | ||
| module: { | ||
| rules: [ | ||
| { | ||
| test: /\.tsx?$/, | ||
| loader: 'ts-loader', | ||
| }, | ||
| { | ||
| test: /\.svg$/i, | ||
| loader: 'url-loader', | ||
| options: { | ||
| generator: (content) => svgToMiniDataURI(content.toString()), | ||
| function getWebpackConfigs() { | ||
| const isDevelopment = process.env.NODE_ENV === 'development'; | ||
| console.log(`[pvaPublish] Generating ${isDevelopment ? 'development' : 'production'} bundles.`); | ||
|
|
||
| return [ | ||
| { | ||
| entry: './src/ui/index.tsx', | ||
| mode: isDevelopment ? 'development' : 'production', | ||
| devtool: isDevelopment ? 'source-map' : undefined, | ||
| output: { | ||
| filename: 'publish-bundle.js', | ||
| path: resolve(__dirname, 'lib', 'ui'), | ||
| }, | ||
| externals: { | ||
| // expect react & react-dom to be available in the extension host iframe | ||
| react: 'React', | ||
| 'react-dom': 'ReactDOM', | ||
| }, | ||
| module: { | ||
| rules: [ | ||
| { | ||
| test: /\.tsx?$/, | ||
| loader: 'ts-loader', | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| resolve: { | ||
| extensions: ['.js', '.ts', '.tsx'], | ||
| }, | ||
| plugins: [], | ||
| }, | ||
| { | ||
| entry: './src/node/index.ts', | ||
| mode: 'production', | ||
| devtool: 'source-map', | ||
| target: 'node', | ||
| output: { | ||
| path: resolve(__dirname, 'lib', 'node'), | ||
| filename: 'index.js', | ||
| libraryTarget: 'commonjs2', | ||
| }, | ||
| module: { | ||
| rules: [{ test: /\.tsx?$/, use: 'ts-loader', exclude: [/node_modules/] }], | ||
| { | ||
| test: /\.svg$/i, | ||
| loader: 'url-loader', | ||
| options: { | ||
| generator: (content) => svgToMiniDataURI(content.toString()), | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| resolve: { | ||
| extensions: ['.js', '.ts', '.tsx'], | ||
| }, | ||
| plugins: [], | ||
| }, | ||
| resolve: { | ||
| extensions: ['.js', '.ts', '.tsx'], | ||
| { | ||
| entry: './src/node/index.ts', | ||
| mode: isDevelopment ? 'development' : 'production', | ||
| target: 'node', | ||
| devtool: isDevelopment ? 'source-map' : undefined, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this be the other way around?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want it to behave like this:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. interesting. it's usually the other way around. until we start reporting errors, I guess it doesn't matter too much.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would think you would want source maps when developing so you can step through your code and work out any bugs, and then you would not want them in production to reduce size and because you aren't often debugging the production code. We also don't copy the source files of the extensions into the production app so the source maps wouldn't even work would they?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally, you would use something like |
||
| output: { | ||
| path: resolve(__dirname, 'lib', 'node'), | ||
| filename: 'index.js', | ||
| libraryTarget: 'commonjs2', | ||
| /** | ||
| * Node files aren't being loaded by Webpack, so we want the source maps to point to the files on disk | ||
| */ | ||
| devtoolModuleFilenameTemplate: isDevelopment ? '[absolute-resource-path]' : undefined, | ||
| }, | ||
| module: { | ||
| rules: [{ test: /\.tsx?$/, use: 'ts-loader', exclude: [/node_modules/] }], | ||
| }, | ||
| resolve: { | ||
| extensions: ['.js', '.ts', '.tsx'], | ||
| }, | ||
| }, | ||
| }, | ||
| ]; | ||
| ]; | ||
| } | ||
|
|
||
| module.exports = getWebpackConfigs(); | ||
Uh oh!
There was an error while loading. Please reload this page.