forked from mermaid-js/mermaid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: group webpack & ignore dist & support yarn1.x (mermaid-js#2551)
- Loading branch information
Showing
26 changed files
with
835 additions
and
144,456 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 |
---|---|---|
|
@@ -4,7 +4,7 @@ node_modules/ | |
coverage/ | ||
.idea/ | ||
|
||
dist/ | ||
dist | ||
|
||
yarn-error.log | ||
.npmrc | ||
|
Empty file.
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
"*.{js,html,md}": [ | ||
"yarn lint:fix" | ||
] | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { merge, mergeWithCustomize, customizeObject } from 'webpack-merge'; | ||
import nodeExternals from 'webpack-node-externals'; | ||
import baseConfig from './webpack.config.base'; | ||
|
||
export default (_env, args) => { | ||
switch (args.mode) { | ||
case 'development': | ||
return [ | ||
baseConfig, | ||
merge(baseConfig, { | ||
externals: [nodeExternals()], | ||
output: { | ||
filename: '[name].core.js', | ||
}, | ||
}), | ||
]; | ||
case 'production': | ||
return [ | ||
// umd | ||
merge(baseConfig, { | ||
output: { | ||
filename: '[name].min.js', | ||
}, | ||
}), | ||
// esm | ||
mergeWithCustomize({ | ||
customizeObject: customizeObject({ | ||
'output.library': 'replace', | ||
}), | ||
})(baseConfig, { | ||
experiments: { | ||
outputModule: true, | ||
}, | ||
output: { | ||
library: { | ||
type: 'module', | ||
}, | ||
filename: '[name].esm.min.mjs', | ||
}, | ||
}), | ||
]; | ||
default: | ||
throw new Error('No matching configuration was found!'); | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import path from 'path'; | ||
|
||
export const resolveRoot = (...relativePath) => path.resolve(__dirname, '..', ...relativePath); | ||
|
||
export default { | ||
amd: false, // https://github.com/lodash/lodash/issues/3052 | ||
target: 'web', | ||
entry: { | ||
mermaid: './src/mermaid.js', | ||
}, | ||
resolve: { | ||
extensions: ['.wasm', '.mjs', '.js', '.json', '.jison'], | ||
fallback: { | ||
fs: false, // jison generated code requires 'fs' | ||
path: require.resolve('path-browserify'), | ||
}, | ||
}, | ||
output: { | ||
path: resolveRoot('./dist'), | ||
filename: '[name].js', | ||
library: { | ||
name: 'mermaid', | ||
type: 'umd', | ||
export: 'default', | ||
}, | ||
globalObject: 'typeof self !== "undefined" ? self : this', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
include: [resolveRoot('./src'), resolveRoot('./node_modules/dagre-d3-renderer/lib')], | ||
use: { | ||
loader: 'babel-loader', | ||
}, | ||
}, | ||
{ | ||
// load scss to string | ||
test: /\.scss$/, | ||
use: ['css-to-string-loader', 'css-loader', 'sass-loader'], | ||
}, | ||
{ | ||
test: /\.jison$/, | ||
use: { | ||
loader: path.resolve(__dirname, './loaders/jison.js'), | ||
options: { | ||
'token-stack': true, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
devtool: 'source-map', | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import baseConfig, { resolveRoot } from './webpack.config.base'; | ||
import { merge } from 'webpack-merge'; | ||
|
||
export default merge(baseConfig, { | ||
mode: 'development', | ||
entry: { | ||
mermaid: './src/mermaid.js', | ||
e2e: './cypress/platform/viewer.js', | ||
'bundle-test': './cypress/platform/bundle-test.js', | ||
}, | ||
output: { | ||
globalObject: 'window', | ||
}, | ||
devServer: { | ||
compress: true, | ||
port: 9000, | ||
static: [ | ||
{ directory: resolveRoot('cypress', 'platform') }, | ||
{ directory: resolveRoot('dist') }, | ||
{ directory: resolveRoot('demos') }, | ||
], | ||
}, | ||
externals: { | ||
mermaid: 'mermaid', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
}, | ||
}, | ||
], | ||
}, | ||
}); |
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
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
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
Oops, something went wrong.