@getgreenspark/widgets
Version:
An SDK design to help the use of Greenspark's widget API in the browser
48 lines (45 loc) • 1.04 kB
JavaScript
const path = require('path')
const Dotenv = require('dotenv-webpack')
var PACKAGE = require('./package.json')
const versionedEntries = {
[PACKAGE.version]: {
import: './src/index.ts',
library: { type: 'commonjs-static' },
},
[`${PACKAGE.version}-umd`]: {
import: './src/index.ts',
},
}
module.exports = (env, { mode }) => {
const isProduction = mode === 'production'
return {
entry: isProduction
? {
latest: './src/index.ts',
...versionedEntries,
}
: {
...versionedEntries,
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
alias: {
'@': path.resolve(__dirname, 'src/'),
},
},
output: {
filename: 'widgets@[name].js',
path: path.resolve(__dirname, 'dist'),
},
plugins: [new Dotenv({ path: isProduction ? '.env.production' : '.env' })],
}
}