2017-04-16 21:38:48 +08:00
|
|
|
import path from 'path'
|
|
|
|
import nodeExternals from 'webpack-node-externals'
|
2017-04-22 15:40:35 +08:00
|
|
|
import ExtractTextPlugin from 'extract-text-webpack-plugin'
|
2017-04-16 21:38:48 +08:00
|
|
|
|
2017-06-04 12:13:22 +08:00
|
|
|
const rules = [
|
|
|
|
{
|
|
|
|
parser: {
|
|
|
|
amd: false
|
|
|
|
},
|
2017-06-04 15:26:45 +08:00
|
|
|
include: /node_modules\/lodash\// // https://github.com/lodash/lodash/issues/3052
|
2017-06-04 12:13:22 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2017-04-16 21:38:48 +08:00
|
|
|
export const webConfig = () => {
|
|
|
|
return {
|
|
|
|
target: 'web',
|
|
|
|
entry: {
|
|
|
|
mermaid: './src/mermaid.js'
|
|
|
|
},
|
2017-09-03 09:20:39 +08:00
|
|
|
externals: ['fs'],
|
2017-04-16 21:38:48 +08:00
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, './dist/'),
|
|
|
|
filename: '[name].js'
|
2017-04-17 16:47:26 +08:00
|
|
|
},
|
|
|
|
module: {
|
2017-06-04 12:13:22 +08:00
|
|
|
rules: rules.concat([
|
2017-04-17 16:47:26 +08:00
|
|
|
{
|
|
|
|
test: /\.js$/,
|
2017-09-01 18:34:10 +08:00
|
|
|
exclude: /node_modules/,
|
2017-04-17 16:47:26 +08:00
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [
|
|
|
|
['env', {
|
|
|
|
'targets': {
|
|
|
|
'browsers': ['last 3 versions']
|
|
|
|
}
|
|
|
|
}]
|
2017-09-05 21:19:53 +08:00
|
|
|
],
|
|
|
|
plugins: ['lodash']
|
2017-04-17 16:47:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-04 12:13:22 +08:00
|
|
|
])
|
2017-04-16 21:38:48 +08: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 16:47:26 +08:00
|
|
|
},
|
|
|
|
module: {
|
2017-06-04 12:13:22 +08:00
|
|
|
rules: rules.concat([
|
2017-04-17 16:47:26 +08:00
|
|
|
{
|
|
|
|
test: /\.js$/,
|
2017-09-01 18:34:10 +08:00
|
|
|
exclude: /node_modules/,
|
2017-04-17 16:47:26 +08:00
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [
|
|
|
|
['env', {
|
|
|
|
'targets': {
|
2017-05-31 23:17:24 +08:00
|
|
|
'node': '6.9'
|
2017-04-17 16:47:26 +08:00
|
|
|
}
|
|
|
|
}]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-04 12:13:22 +08:00
|
|
|
])
|
2017-04-16 21:38:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-22 15:40:35 +08: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: {
|
2017-06-04 12:13:22 +08:00
|
|
|
rules: rules.concat([
|
2017-04-22 15:40:35 +08:00
|
|
|
{
|
|
|
|
test: /\.less$/,
|
|
|
|
use: ExtractTextPlugin.extract({
|
|
|
|
fallback: 'style-loader',
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'css-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'less-loader'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
}
|
2017-06-04 12:13:22 +08:00
|
|
|
])
|
2017-04-22 15:40:35 +08:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new ExtractTextPlugin('[name].css')
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|