2017-04-16 21:38:48 +08:00
|
|
|
import path from 'path'
|
|
|
|
|
2018-03-09 20:49:12 +08:00
|
|
|
const amdRule = {
|
2017-09-12 21:23:05 +08:00
|
|
|
parser: {
|
2018-03-09 20:49:12 +08:00
|
|
|
amd: false // https://github.com/lodash/lodash/issues/3052
|
|
|
|
}
|
2017-09-12 21:23:05 +08:00
|
|
|
}
|
|
|
|
|
2019-08-03 15:05:43 -07: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')
|
|
|
|
],
|
2017-09-12 21:23:05 +08:00
|
|
|
use: {
|
2018-03-09 20:49:12 +08:00
|
|
|
loader: 'babel-loader'
|
2017-06-04 12:13:22 +08:00
|
|
|
}
|
2017-09-12 21:23:05 +08:00
|
|
|
}
|
|
|
|
|
2018-03-09 16:23:35 +08:00
|
|
|
const scssRule = { // load scss to string
|
|
|
|
test: /\.scss$/,
|
2017-09-12 21:33:39 +08:00
|
|
|
use: [
|
|
|
|
{ loader: 'css-to-string-loader' },
|
|
|
|
{ loader: 'css-loader' },
|
2018-03-09 16:23:35 +08:00
|
|
|
{ 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'
|
|
|
|
},
|
2019-08-03 15:05:43 -07:00
|
|
|
resolve: {
|
|
|
|
extensions: ['.wasm', '.mjs', '.js', '.json', '.jison']
|
|
|
|
},
|
2017-09-11 23:06:34 +08:00
|
|
|
node: {
|
|
|
|
fs: 'empty' // jison generated code requires 'fs'
|
|
|
|
},
|
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'
|
2017-04-17 16:47:26 +08:00
|
|
|
},
|
|
|
|
module: {
|
2019-08-03 15:05:43 -07:00
|
|
|
rules: [amdRule, jsRule, scssRule, jisonRule]
|
2017-12-20 22:20:56 +08:00
|
|
|
},
|
|
|
|
devtool: 'source-map'
|
2017-04-16 21:38:48 +08:00
|
|
|
}
|
|
|
|
}
|