22 * ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
33 *
44 * In order to extend the configuration follow the steps in
5- * https://grafana.com/developers/plugin-tools/get-started/set-up-development-environment #extend-the-webpack-config
5+ * https://grafana.com/developers/plugin-tools/how-to-guides/extend-configurations #extend-the-webpack-config
66 */
77
88import CopyWebpackPlugin from 'copy-webpack-plugin' ;
@@ -19,9 +19,11 @@ import VirtualModulesPlugin from 'webpack-virtual-modules';
1919import { BuildModeWebpackPlugin } from './BuildModeWebpackPlugin.ts' ;
2020import { DIST_DIR , SOURCE_DIR } from './constants.ts' ;
2121import { getCPConfigVersion , getEntries , getPackageJson , getPluginJson , hasReadme , isWSL } from './utils.ts' ;
22+ import { externals } from '../bundler/externals.ts' ;
2223
2324const pluginJson = getPluginJson ( ) ;
2425const cpVersion = getCPConfigVersion ( ) ;
26+ const pluginVersion = getPackageJson ( ) . version ;
2527
2628const virtualPublicPath = new VirtualModulesPlugin ( {
2729 'node_modules/grafana-public-path.js' : `
@@ -54,44 +56,7 @@ const config = async (env: Env): Promise<Configuration> => {
5456
5557 entry : await getEntries ( ) ,
5658
57- externals : [
58- // Required for dynamic publicPath resolution
59- { 'amd-module' : 'module' } ,
60- 'lodash' ,
61- 'jquery' ,
62- 'moment' ,
63- 'slate' ,
64- 'emotion' ,
65- '@emotion/react' ,
66- '@emotion/css' ,
67- 'prismjs' ,
68- 'slate-plain-serializer' ,
69- '@grafana/slate-react' ,
70- 'react' ,
71- 'react-dom' ,
72- 'react-redux' ,
73- 'redux' ,
74- 'rxjs' ,
75- 'react-router' ,
76- 'd3' ,
77- 'angular' ,
78- / ^ @ g r a f a n a \/ u i / i,
79- / ^ @ g r a f a n a \/ r u n t i m e / i,
80- / ^ @ g r a f a n a \/ d a t a / i,
81-
82- // Mark legacy SDK imports as external if their name starts with the "grafana/" prefix
83- ( { request } , callback ) => {
84- const prefix = 'grafana/' ;
85- const hasPrefix = ( request : string ) => request . indexOf ( prefix ) === 0 ;
86- const stripPrefix = ( request : string ) => request . substr ( prefix . length ) ;
87-
88- if ( request && hasPrefix ( request ) ) {
89- return callback ( undefined , stripPrefix ( request ) ) ;
90- }
91-
92- callback ( ) ;
93- } ,
94- ] ,
59+ externals,
9560
9661 // Support WebAssembly according to latest spec - makes WebAssembly module async
9762 experiments : {
@@ -195,7 +160,8 @@ const config = async (env: Env): Promise<Configuration> => {
195160 virtualPublicPath ,
196161 // Insert create plugin version information into the bundle
197162 new webpack . BannerPlugin ( {
198- banner : '/* [create-plugin] version: ' + cpVersion + ' */' ,
163+ banner : `/* [create-plugin] version: ${ cpVersion } */
164+ /* [create-plugin] plugin: ${ pluginJson . id } @${ pluginVersion } */` ,
199165 raw : true ,
200166 entryOnly : true ,
201167 } ) ,
@@ -225,7 +191,7 @@ const config = async (env: Env): Promise<Configuration> => {
225191 rules : [
226192 {
227193 search : / \% V E R S I O N \% / g,
228- replace : getPackageJson ( ) . version ,
194+ replace : pluginVersion ,
229195 } ,
230196 {
231197 search : / \% T O D A Y \% / g,
@@ -254,6 +220,7 @@ const config = async (env: Env): Promise<Configuration> => {
254220 new ESLintPlugin ( {
255221 extensions : [ '.ts' , '.tsx' ] ,
256222 lintDirtyModulesOnly : Boolean ( env . development ) , // don't lint on start, only lint changed files
223+ failOnError : Boolean ( env . production ) ,
257224 } ) ,
258225 ]
259226 : [ ] ) ,
0 commit comments