mermaid/webpack.config.base.js

62 lines
1.3 KiB
JavaScript
Raw Normal View History

import path from 'path';
2017-04-16 21:38:48 +08:00
2018-03-09 20:49:12 +08:00
const amdRule = {
2017-09-12 21:23:05 +08:00
parser: {
amd: false, // https://github.com/lodash/lodash/issues/3052
},
};
2017-09-12 21:23:05 +08:00
const jisonRule = {
test: /\.jison$/,
use: {
loader: path.resolve(__dirname, './jisonLoader'),
options: {
'token-stack': true,
},
},
};
2017-09-12 21:23:05 +08:00
const jsRule = {
test: /\.js$/,
2019-04-26 10:03:23 +02:00
include: [
path.resolve(__dirname, './src'),
path.resolve(__dirname, './node_modules/dagre-d3-renderer/lib'),
2019-04-26 10:03:23 +02:00
],
2017-09-12 21:23:05 +08:00
use: {
loader: 'babel-loader',
},
};
2017-09-12 21:23:05 +08:00
const scssRule = {
// load scss to string
2018-03-09 16:23:35 +08:00
test: /\.scss$/,
use: [{ loader: 'css-to-string-loader' }, { loader: 'css-loader' }, { loader: 'sass-loader' }],
};
2017-09-12 21:33:39 +08:00
2017-09-09 21:47:21 +08:00
export const jsConfig = () => {
2017-04-16 21:38:48 +08:00
return {
2018-03-06 14:37:27 +08:00
mode: 'development',
2017-04-16 21:38:48 +08:00
target: 'web',
entry: {
mermaid: './src/mermaid.js',
2017-04-16 21:38:48 +08:00
},
resolve: {
extensions: ['.wasm', '.mjs', '.js', '.json', '.jison'],
},
2021-07-15 21:00:39 +02:00
node: {
fs: 'empty', // jison generated code requires 'fs'
2021-07-15 21:00:39 +02:00
},
2017-04-16 21:38:48 +08:00
output: {
path: path.join(__dirname, './dist/'),
2017-09-09 21:47:21 +08:00
filename: '[name].js',
library: 'mermaid',
libraryTarget: 'umd',
libraryExport: 'default',
globalObject: 'typeof self !== "undefined" ? self : this',
2017-04-17 16:47:26 +08:00
},
module: {
rules: [amdRule, jsRule, scssRule, jisonRule],
2017-12-20 22:20:56 +08:00
},
devtool: 'source-map',
};
};