2017-04-16 15:38:48 +02:00
|
|
|
import path from 'path'
|
|
|
|
import nodeExternals from 'webpack-node-externals'
|
2017-04-22 09:40:35 +02:00
|
|
|
import ExtractTextPlugin from 'extract-text-webpack-plugin'
|
2017-04-16 15:38:48 +02:00
|
|
|
|
|
|
|
export const webConfig = () => {
|
|
|
|
return {
|
|
|
|
target: 'web',
|
|
|
|
entry: {
|
|
|
|
mermaid: './src/mermaid.js'
|
|
|
|
},
|
|
|
|
externals: 'fs',
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, './dist/'),
|
|
|
|
filename: '[name].js'
|
2017-04-17 10:47:26 +02:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [
|
|
|
|
['env', {
|
|
|
|
'targets': {
|
|
|
|
'browsers': ['last 3 versions']
|
|
|
|
}
|
|
|
|
}]
|
2017-04-17 16:34:25 +02:00
|
|
|
],
|
|
|
|
plugins: [
|
|
|
|
'transform-remove-strict-mode'
|
2017-04-17 10:47:26 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2017-04-16 15:38:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const nodeConfig = () => {
|
|
|
|
return {
|
|
|
|
target: 'node',
|
|
|
|
entry: {
|
|
|
|
mermaidAPI: './src/mermaidAPI.js'
|
|
|
|
},
|
|
|
|
externals: [nodeExternals()],
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, './dist/'),
|
|
|
|
filename: '[name].js',
|
|
|
|
libraryTarget: 'commonjs2'
|
2017-04-17 10:47:26 +02:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [
|
|
|
|
['env', {
|
|
|
|
'targets': {
|
|
|
|
'node': 4.2
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2017-04-16 15:38:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-22 09:40:35 +02:00
|
|
|
|
|
|
|
export const lessConfig = () => {
|
|
|
|
return {
|
|
|
|
target: 'web',
|
|
|
|
entry: {
|
|
|
|
'mermaid': './src/less/default/mermaid.less',
|
|
|
|
'mermaid.dark': './src/less/dark/mermaid.less',
|
|
|
|
'mermaid.forest': './src/less/forest/mermaid.less',
|
|
|
|
'mermaid.neutral': './src/less/neutral/mermaid.less'
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, './dist/'),
|
|
|
|
filename: '[name].css'
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
|
|
|
use: ExtractTextPlugin.extract({
|
|
|
|
fallback: 'style-loader',
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'css-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'less-loader'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new ExtractTextPlugin('[name].css')
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|