forked from mermaid-js/mermaid
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8073c7
commit c808ec3
Showing
2 changed files
with
41 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,72 @@ | ||
import path from 'path'; | ||
const { ESBuildMinifyPlugin } = require('esbuild-loader'); | ||
|
||
const amdRule = { | ||
parser: { | ||
amd: false, // https://github.com/lodash/lodash/issues/3052 | ||
}, | ||
amd: false // https://github.com/lodash/lodash/issues/3052 | ||
} | ||
}; | ||
|
||
const jisonRule = { | ||
test: /\.jison$/, | ||
use: { | ||
loader: path.resolve(__dirname, './jisonLoader'), | ||
options: { | ||
'token-stack': true, | ||
}, | ||
}, | ||
'token-stack': true | ||
} | ||
} | ||
}; | ||
const jsRule = { | ||
test: /\.js$/, | ||
include: [ | ||
path.resolve(__dirname, './src'), | ||
path.resolve(__dirname, './node_modules/dagre-d3-renderer/lib'), | ||
path.resolve(__dirname, './node_modules/dagre-d3-renderer/lib') | ||
], | ||
use: { | ||
loader: 'babel-loader', | ||
}, | ||
loader: 'esbuild-loader', | ||
options: { | ||
target: 'es2015' | ||
} | ||
} | ||
}; | ||
|
||
const scssRule = { | ||
// load scss to string | ||
test: /\.scss$/, | ||
use: [{ loader: 'css-to-string-loader' }, { loader: 'css-loader' }, { loader: 'sass-loader' }], | ||
use: [{ loader: 'css-to-string-loader' }, { loader: 'css-loader' }, { loader: 'sass-loader' }] | ||
}; | ||
|
||
export const jsConfig = () => { | ||
return { | ||
mode: 'development', | ||
target: 'web', | ||
entry: { | ||
mermaid: './src/mermaid.js', | ||
mermaid: './src/mermaid.js' | ||
}, | ||
resolve: { | ||
extensions: ['.wasm', '.mjs', '.js', '.json', '.jison'], | ||
extensions: ['.wasm', '.mjs', '.js', '.json', '.jison'] | ||
}, | ||
node: { | ||
fs: 'empty', // jison generated code requires 'fs' | ||
fs: 'empty' // jison generated code requires 'fs' | ||
}, | ||
output: { | ||
path: path.join(__dirname, './dist/'), | ||
filename: '[name].js', | ||
library: 'mermaid', | ||
libraryTarget: 'umd', | ||
libraryExport: 'default', | ||
globalObject: 'typeof self !== "undefined" ? self : this', | ||
globalObject: 'typeof self !== "undefined" ? self : this' | ||
}, | ||
module: { | ||
rules: [amdRule, jsRule, scssRule, jisonRule], | ||
rules: [amdRule, jsRule, scssRule, jisonRule] | ||
}, | ||
devtool: 'source-map', | ||
optimization: { | ||
minimizer: [ | ||
new ESBuildMinifyPlugin({ | ||
target: 'es2015' | ||
}) | ||
] | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters