2019-11-27 19:09:14 +01:00
|
|
|
import path from 'path';
|
2017-04-16 21:38:48 +08:00
|
|
|
|
2019-08-03 15:05:43 -07:00
|
|
|
const jisonRule = {
|
|
|
|
test: /\.jison$/,
|
|
|
|
use: {
|
|
|
|
loader: path.resolve(__dirname, './jisonLoader'),
|
|
|
|
options: {
|
2021-07-29 21:48:46 +02:00
|
|
|
'token-stack': true,
|
|
|
|
},
|
|
|
|
},
|
2019-11-27 19:09:14 +01:00
|
|
|
};
|
2021-09-21 07:37:11 +00:00
|
|
|
|
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'),
|
2021-07-29 21:48:46 +02:00
|
|
|
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: {
|
2021-07-29 21:48:46 +02:00
|
|
|
loader: 'babel-loader',
|
|
|
|
},
|
2019-11-27 19:09:14 +01:00
|
|
|
};
|
2017-09-12 21:23:05 +08:00
|
|
|
|
2019-11-27 19:09:14 +01:00
|
|
|
const scssRule = {
|
|
|
|
// load scss to string
|
2018-03-09 16:23:35 +08:00
|
|
|
test: /\.scss$/,
|
2021-07-29 21:48:46 +02:00
|
|
|
use: [{ loader: 'css-to-string-loader' }, { loader: 'css-loader' }, { loader: 'sass-loader' }],
|
2019-11-27 19:09:14 +01:00
|
|
|
};
|
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 {
|
2021-09-21 07:37:11 +00:00
|
|
|
amd: false, // https://github.com/lodash/lodash/issues/3052
|
2018-03-06 14:37:27 +08:00
|
|
|
mode: 'development',
|
2017-04-16 21:38:48 +08:00
|
|
|
target: 'web',
|
|
|
|
entry: {
|
2021-07-29 21:48:46 +02:00
|
|
|
mermaid: './src/mermaid.js',
|
2017-04-16 21:38:48 +08:00
|
|
|
},
|
2019-08-03 15:05:43 -07:00
|
|
|
resolve: {
|
2021-07-29 21:48:46 +02:00
|
|
|
extensions: ['.wasm', '.mjs', '.js', '.json', '.jison'],
|
2021-09-21 07:37:11 +00:00
|
|
|
fallback: {
|
|
|
|
fs: false, // jison generated code requires 'fs'
|
|
|
|
path: require.resolve('path-browserify'),
|
|
|
|
},
|
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',
|
2021-09-21 07:37:11 +00:00
|
|
|
library: {
|
|
|
|
name: 'mermaid',
|
|
|
|
type: 'umd',
|
|
|
|
export: 'default',
|
|
|
|
},
|
2021-07-29 21:48:46 +02:00
|
|
|
globalObject: 'typeof self !== "undefined" ? self : this',
|
2017-04-17 16:47:26 +08:00
|
|
|
},
|
|
|
|
module: {
|
2021-09-21 07:37:11 +00:00
|
|
|
rules: [jsRule, scssRule, jisonRule],
|
2017-12-20 22:20:56 +08:00
|
|
|
},
|
2021-07-29 21:48:46 +02:00
|
|
|
devtool: 'source-map',
|
2019-11-27 19:09:14 +01:00
|
|
|
};
|
|
|
|
};
|