2017-04-16 21:38:48 +08:00
|
|
|
import path from 'path'
|
|
|
|
|
2017-09-12 21:23:05 +08:00
|
|
|
const lodashRule = {
|
|
|
|
parser: {
|
|
|
|
amd: false
|
|
|
|
},
|
|
|
|
include: /node_modules\/lodash\// // https://github.com/lodash/lodash/issues/3052
|
|
|
|
}
|
|
|
|
|
|
|
|
const jsRule = {
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [
|
2017-12-20 22:20:56 +08:00
|
|
|
'env'
|
2017-09-12 21:23:05 +08:00
|
|
|
],
|
|
|
|
plugins: ['lodash']
|
|
|
|
}
|
2017-06-04 12:13:22 +08:00
|
|
|
}
|
2017-09-12 21:23:05 +08:00
|
|
|
}
|
|
|
|
|
2017-09-12 22:06:19 +08:00
|
|
|
const lessRule = { // load less to string
|
2017-09-12 21:33:39 +08:00
|
|
|
test: /\.less$/,
|
|
|
|
use: [
|
|
|
|
{ loader: 'css-to-string-loader' },
|
|
|
|
{ loader: 'css-loader' },
|
|
|
|
{ loader: 'less-loader' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
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-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: {
|
2017-09-12 22:06:19 +08:00
|
|
|
rules: [lodashRule, jsRule, lessRule]
|
2017-12-20 22:20:56 +08:00
|
|
|
},
|
|
|
|
devtool: 'source-map'
|
2017-04-16 21:38:48 +08:00
|
|
|
}
|
|
|
|
}
|