-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: JoseSantosAMD <Jose.Santos@amd.com>
- Loading branch information
1 parent
3137076
commit 43d492d
Showing
2 changed files
with
227 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ | ||
* | ||
* In order to extend the configuration follow the steps in | ||
* https://grafana.github.io/plugin-tools/docs/advanced-configuration#extending-the-typescript-config | ||
*/ | ||
{ | ||
"compilerOptions": { | ||
"alwaysStrict": true, | ||
"declaration": false, | ||
"rootDir": "../src", | ||
"baseUrl": "../src", | ||
"typeRoots": ["../node_modules/@types"], | ||
"resolveJsonModule": true | ||
}, | ||
"ts-node": { | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es5", | ||
"esModuleInterop": true | ||
}, | ||
"transpileOnly": true | ||
}, | ||
"include": ["../src", "./types"], | ||
"extends": "@grafana/tsconfig" | ||
} |
201 changes: 201 additions & 0 deletions
201
grafana_plugins/svg_plugin/.config/webpack/webpack.config.ts
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 |
---|---|---|
@@ -0,0 +1,201 @@ | ||
/* | ||
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ | ||
* | ||
* In order to extend the configuration follow the steps in | ||
* https://grafana.github.io/plugin-tools/docs/advanced-configuration#extending-the-webpack-config | ||
*/ | ||
|
||
import CopyWebpackPlugin from 'copy-webpack-plugin'; | ||
import ESLintPlugin from 'eslint-webpack-plugin'; | ||
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; | ||
import LiveReloadPlugin from 'webpack-livereload-plugin'; | ||
import path from 'path'; | ||
import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin'; | ||
import { Configuration } from 'webpack'; | ||
|
||
import { getPackageJson, getPluginJson, hasReadme, getEntries } from './utils'; | ||
import { SOURCE_DIR, DIST_DIR } from './constants'; | ||
|
||
const pluginJson = getPluginJson(); | ||
|
||
const config = async (env): Promise<Configuration> => ({ | ||
cache: { | ||
type: 'filesystem', | ||
buildDependencies: { | ||
config: [__filename], | ||
}, | ||
}, | ||
|
||
context: path.join(process.cwd(), SOURCE_DIR), | ||
|
||
devtool: env.production ? 'source-map' : 'eval-source-map', | ||
|
||
entry: await getEntries(), | ||
|
||
externals: [ | ||
'lodash', | ||
'jquery', | ||
'moment', | ||
'slate', | ||
'emotion', | ||
'@emotion/react', | ||
'@emotion/css', | ||
'prismjs', | ||
'slate-plain-serializer', | ||
'@grafana/slate-react', | ||
'react', | ||
'react-dom', | ||
'react-redux', | ||
'redux', | ||
'rxjs', | ||
'react-router', | ||
'react-router-dom', | ||
'd3', | ||
'angular', | ||
'@grafana/ui', | ||
'@grafana/runtime', | ||
'@grafana/data', | ||
|
||
// Mark legacy SDK imports as external if their name starts with the "grafana/" prefix | ||
({ request }, callback) => { | ||
const prefix = 'grafana/'; | ||
const hasPrefix = (request) => request.indexOf(prefix) === 0; | ||
const stripPrefix = (request) => request.substr(prefix.length); | ||
|
||
if (hasPrefix(request)) { | ||
return callback(undefined, stripPrefix(request)); | ||
} | ||
|
||
callback(); | ||
}, | ||
], | ||
|
||
mode: env.production ? 'production' : 'development', | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
exclude: /(node_modules)/, | ||
test: /\.[tj]sx?$/, | ||
use: { | ||
loader: 'swc-loader', | ||
options: { | ||
jsc: { | ||
baseUrl: './src', | ||
target: 'es2015', | ||
loose: false, | ||
parser: { | ||
syntax: 'typescript', | ||
tsx: true, | ||
decorators: false, | ||
dynamicImport: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
test: /\.css$/, | ||
use: ["style-loader", "css-loader"] | ||
}, | ||
{ | ||
test: /\.s[ac]ss$/, | ||
use: ['style-loader', 'css-loader', 'sass-loader'], | ||
}, | ||
{ | ||
test: /\.(png|jpe?g|gif|svg)$/, | ||
type: 'asset/resource', | ||
generator: { | ||
// Keep publicPath relative for host.com/grafana/ deployments | ||
publicPath: `public/plugins/${pluginJson.id}/img/`, | ||
outputPath: 'img/', | ||
filename: Boolean(env.production) ? '[hash][ext]' : '[name][ext]', | ||
}, | ||
}, | ||
{ | ||
test: /\.(woff|woff2|eot|ttf|otf)(\?v=\d+\.\d+\.\d+)?$/, | ||
type: 'asset/resource', | ||
generator: { | ||
// Keep publicPath relative for host.com/grafana/ deployments | ||
publicPath: `public/plugins/${pluginJson.id}/fonts/`, | ||
outputPath: 'fonts/', | ||
filename: Boolean(env.production) ? '[hash][ext]' : '[name][ext]', | ||
}, | ||
}, | ||
], | ||
}, | ||
|
||
output: { | ||
clean: { | ||
keep: new RegExp(`.*?_(amd64|arm(64)?)(.exe)?`), | ||
}, | ||
filename: '[name].js', | ||
library: { | ||
type: 'amd', | ||
}, | ||
path: path.resolve(process.cwd(), DIST_DIR), | ||
publicPath: '/', | ||
}, | ||
|
||
plugins: [ | ||
new CopyWebpackPlugin({ | ||
patterns: [ | ||
// If src/README.md exists use it; otherwise the root README | ||
// To `compiler.options.output` | ||
{ from: hasReadme() ? 'README.md' : '../README.md', to: '.', force: true }, | ||
{ from: 'plugin.json', to: '.' }, | ||
{ from: '../LICENSE', to: '.' }, | ||
{ from: '../CHANGELOG.md', to: '.', force: true }, | ||
{ from: '**/*.json', to: '.' }, // TODO<Add an error for checking the basic structure of the repo> | ||
{ from: '**/*.svg', to: '.', noErrorOnMissing: true }, // Optional | ||
{ from: '**/*.png', to: '.', noErrorOnMissing: true }, // Optional | ||
{ from: '**/*.html', to: '.', noErrorOnMissing: true }, // Optional | ||
{ from: 'img/**/*', to: '.', noErrorOnMissing: true }, // Optional | ||
{ from: 'libs/**/*', to: '.', noErrorOnMissing: true }, // Optional | ||
{ from: 'static/**/*', to: '.', noErrorOnMissing: true }, // Optional | ||
], | ||
}), | ||
// Replace certain template-variables in the README and plugin.json | ||
new ReplaceInFileWebpackPlugin([ | ||
{ | ||
dir: DIST_DIR, | ||
files: ['plugin.json', 'README.md'], | ||
rules: [ | ||
{ | ||
search: /\%VERSION\%/g, | ||
replace: getPackageJson().version, | ||
}, | ||
{ | ||
search: /\%TODAY\%/g, | ||
replace: new Date().toISOString().substring(0, 10), | ||
}, | ||
{ | ||
search: /\%PLUGIN_ID\%/g, | ||
replace: pluginJson.id, | ||
}, | ||
], | ||
}, | ||
]), | ||
new ForkTsCheckerWebpackPlugin({ | ||
async: Boolean(env.development), | ||
issue: { | ||
include: [{ file: '**/*.{ts,tsx}' }], | ||
}, | ||
typescript: { configFile: path.join(process.cwd(), 'tsconfig.json') }, | ||
}), | ||
new ESLintPlugin({ | ||
extensions: ['.ts', '.tsx'], | ||
lintDirtyModulesOnly: Boolean(env.development), // don't lint on start, only lint changed files | ||
}), | ||
...(env.development ? [new LiveReloadPlugin()] : []), | ||
], | ||
|
||
resolve: { | ||
extensions: ['.js', '.jsx', '.ts', '.tsx'], | ||
// handle resolving "rootDir" paths | ||
modules: [path.resolve(process.cwd(), 'src'), 'node_modules'], | ||
unsafeCache: true, | ||
}, | ||
}); | ||
|
||
export default config; |