mirror of
https://github.com/Redocly/redoc.git
synced 2024-12-01 21:03:45 +03:00
Build and publish angular2 module (fixes #126)
This commit is contained in:
parent
5597a58846
commit
02b061cbd8
|
@ -10,7 +10,9 @@ const BANNER =
|
||||||
Version: ${VERSION}
|
Version: ${VERSION}
|
||||||
Repo: https://github.com/Rebilly/ReDoc`;
|
Repo: https://github.com/Rebilly/ReDoc`;
|
||||||
|
|
||||||
module.exports = {
|
const IS_MODULE = process.env.IS_MODULE != null;
|
||||||
|
|
||||||
|
const config = {
|
||||||
context: root(),
|
context: root(),
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
|
|
||||||
|
@ -35,13 +37,13 @@ module.exports = {
|
||||||
setImmediate: false
|
setImmediate: false
|
||||||
},
|
},
|
||||||
entry: {
|
entry: {
|
||||||
'redoc': ['./lib/polyfills.ts', './lib/vendor.ts', './lib/index.ts']
|
'redoc': IS_MODULE ? ['./lib/vendor.ts', './lib/redoc.module.ts'] : ['./lib/polyfills.ts', './lib/vendor.ts', './lib/index.ts']
|
||||||
},
|
},
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
path: root('dist'),
|
path: root('dist'),
|
||||||
filename: '[name].min.js',
|
filename: IS_MODULE ? '[name]-module.js' : '[name].min.js',
|
||||||
sourceMapFilename: '[name].min.map',
|
sourceMapFilename: IS_MODULE ? '[name]-module.map' : '[name].min.map',
|
||||||
library: 'Redoc',
|
library: 'Redoc',
|
||||||
libraryTarget: 'umd',
|
libraryTarget: 'umd',
|
||||||
umdNamedDefine: true
|
umdNamedDefine: true
|
||||||
|
@ -60,9 +62,14 @@ module.exports = {
|
||||||
test: /\.ts$/,
|
test: /\.ts$/,
|
||||||
loader: 'awesome-typescript-loader',
|
loader: 'awesome-typescript-loader',
|
||||||
exclude: /(node_modules)/
|
exclude: /(node_modules)/
|
||||||
|
}, {
|
||||||
|
test: /lib[\\\/].*\.css$/,
|
||||||
|
loaders: ['raw-loader'],
|
||||||
|
exclude: [/redoc-initial-styles\.css$/]
|
||||||
}, {
|
}, {
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
loaders: ['style', 'css?-import']
|
loaders: ['style', 'css?-import'],
|
||||||
|
exclude: [/lib[\\\/](?!.*redoc-initial-styles).*\.css$/]
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -90,3 +97,31 @@ module.exports = {
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_MODULE) {
|
||||||
|
config.externals = {
|
||||||
|
'jquery': 'jQuery',
|
||||||
|
'esprima': 'esprima', // optional dep of ys-yaml not needed for redoc
|
||||||
|
'@angular/platform-browser-dynamic': '@angular/platform-browser-dynamic',
|
||||||
|
'@angular/platform-browser': '@angular/platform-browser',
|
||||||
|
'@angular/core': '@angular/core',
|
||||||
|
'@angular/common': '@angular/common',
|
||||||
|
'@angular/forms': '@angular/forms',
|
||||||
|
'core-js': 'core-js',
|
||||||
|
'rxjs': 'rxjs',
|
||||||
|
'zone.js/dist/zone': 'zone.js/dist/zone'
|
||||||
|
};
|
||||||
|
|
||||||
|
config.module.rules.push({
|
||||||
|
test: /\.ts$/,
|
||||||
|
loader: 'angular2-template-loader',
|
||||||
|
exclude: [/\.(spec|e2e)\.ts$/]
|
||||||
|
});
|
||||||
|
|
||||||
|
config.module.rules.push({
|
||||||
|
test: /\.html$/,
|
||||||
|
loader: 'raw-loader'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = config;
|
||||||
|
|
24
package.json
24
package.json
|
@ -21,7 +21,7 @@
|
||||||
"ngc": "ngc -p .",
|
"ngc": "ngc -p .",
|
||||||
"webpack:prod": "webpack --config build/webpack.prod.js --profile --bail",
|
"webpack:prod": "webpack --config build/webpack.prod.js --profile --bail",
|
||||||
"build:sass": "node-sass -q -o lib lib",
|
"build:sass": "node-sass -q -o lib lib",
|
||||||
"build:prod": "npm run build:sass && npm run ngc && npm run webpack:prod",
|
"build:prod": "npm run build:sass && npm run ngc && npm run webpack:prod && IS_MODULE=true npm run webpack:prod",
|
||||||
"build-dist": "npm run build:prod",
|
"build-dist": "npm run build:prod",
|
||||||
"stats": "webpack --config build/webpack.prod.js --json > stats.json",
|
"stats": "webpack --config build/webpack.prod.js --json > stats.json",
|
||||||
"start": "webpack-dev-server --config build/webpack.dev.js --content-base demo",
|
"start": "webpack-dev-server --config build/webpack.dev.js --content-base demo",
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
"author": "Roman Hotsiy",
|
"author": "Roman Hotsiy",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular/compiler-cli": "^0.6.3",
|
"@angular/compiler-cli": "^2.1.0",
|
||||||
"@types/core-js": "^0.9.31",
|
"@types/core-js": "^0.9.31",
|
||||||
"@types/jasmine": "^2.2.32",
|
"@types/jasmine": "^2.2.32",
|
||||||
"@types/requirejs": "^2.1.26",
|
"@types/requirejs": "^2.1.26",
|
||||||
|
@ -91,13 +91,6 @@
|
||||||
"webpack-dev-server": "^2.1.0-beta.6"
|
"webpack-dev-server": "^2.1.0-beta.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/common": "^2.0.1",
|
|
||||||
"@angular/compiler": "^2.0.1",
|
|
||||||
"@angular/core": "^2.0.1",
|
|
||||||
"@angular/platform-browser": "^2.0.1",
|
|
||||||
"@angular/platform-browser-dynamic": "^2.0.1",
|
|
||||||
"@angular/platform-server": "^2.0.1",
|
|
||||||
"core-js": "^2.4.1",
|
|
||||||
"dropkickjs": "^2.1.10",
|
"dropkickjs": "^2.1.10",
|
||||||
"hint.css": "^2.3.2",
|
"hint.css": "^2.3.2",
|
||||||
"json-pointer": "^0.5.0",
|
"json-pointer": "^0.5.0",
|
||||||
|
@ -105,10 +98,19 @@
|
||||||
"openapi-sampler": "^0.3.1",
|
"openapi-sampler": "^0.3.1",
|
||||||
"prismjs": "^1.5.1",
|
"prismjs": "^1.5.1",
|
||||||
"remarkable": "^1.6.2",
|
"remarkable": "^1.6.2",
|
||||||
"rxjs": "^5.0.0-beta.12",
|
|
||||||
"scrollparent": "^1.0.0",
|
"scrollparent": "^1.0.0",
|
||||||
"slugify": "^1.0.2",
|
"slugify": "^1.0.2",
|
||||||
"stream-http": "^2.3.1",
|
"stream-http": "^2.3.1"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@angular/common": "^2.1.0",
|
||||||
|
"@angular/compiler": "^2.1.0",
|
||||||
|
"@angular/core": "^2.1.0",
|
||||||
|
"@angular/platform-browser": "^2.1.0",
|
||||||
|
"@angular/platform-browser-dynamic": "^2.1.0",
|
||||||
|
"@angular/platform-server": "^2.1.0",
|
||||||
|
"core-js": "^2.4.1",
|
||||||
|
"rxjs": "^5.0.0-beta.12",
|
||||||
"zone.js": "^0.6.25"
|
"zone.js": "^0.6.25"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user