redoc/build/webpack.dev.js

103 lines
2.2 KiB
JavaScript
Raw Normal View History

2016-08-28 21:46:10 +03:00
const webpack = require('webpack');
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
const root = require('./helpers').root;
const VERSION = JSON.stringify(require('../package.json').version);
const IS_PRODUCTION = process.env.NODE_ENV === "production";
2016-08-28 21:46:10 +03:00
// TODO Refactor common parts of config
module.exports = {
context: root(),
devtool: 'source-map',
2016-08-28 21:46:10 +03:00
resolve: {
2016-09-27 09:03:04 +03:00
extensions: ['.ts', '.js', '.json', '.css'],
2016-08-28 21:46:10 +03:00
alias: {
http: 'stream-http',
https: 'stream-http'
}
},
externals: {
"jquery": "jQuery",
'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc
2016-08-28 21:46:10 +03:00
},
node: {
fs: "empty",
crypto: "empty",
2016-09-27 09:03:04 +03:00
global: true,
process: true,
module: false,
clearImmediate: false,
setImmediate: false
2016-08-28 21:46:10 +03:00
},
entry: {
'redoc': './lib/index.ts',
'vendor': './lib/vendor.ts',
'polyfills': './lib/polyfills.ts'
},
devServer: {
outputPath: root('dist'),
watchOptions: {
poll: true
},
port: 9000,
hot: false,
stats: 'errors-only'
2016-08-28 21:46:10 +03:00
},
output: {
path: root('dist'),
filename: '[name].js',
sourceMapFilename: '[name].[id].map',
2016-08-28 21:46:10 +03:00
chunkFilename: '[id].chunk.js'
},
module: {
exprContextCritical: false,
rules: [{
2016-09-27 09:03:04 +03:00
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader',
exclude: [
/node_modules/
]
2016-09-27 09:03:04 +03:00
}, {
2016-08-28 21:46:10 +03:00
test: /\.ts$/,
loaders: [
'awesome-typescript-loader',
'angular2-template-loader'
],
exclude: [/\.(spec|e2e)\.ts$/]
2016-09-27 09:03:04 +03:00
}, {
test: /lib[\\\/].*\.css$/,
2016-08-28 21:46:10 +03:00
loaders: ['raw-loader'],
exclude: [/redoc-initial-styles\.css$/]
2016-09-27 09:03:04 +03:00
}, {
2016-08-28 21:46:10 +03:00
test: /\.css$/,
loaders: ['style', 'css?-import'],
exclude: [/lib[\\\/](?!.*redoc-initial-styles).*\.css$/]
2016-09-27 09:03:04 +03:00
}, {
2016-08-28 21:46:10 +03:00
test: /\.html$/,
loader: 'raw-loader'
}]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: ['vendor', 'polyfills'],
minChunks: Infinity
}),
new webpack.DefinePlugin({
'IS_PRODUCTION': IS_PRODUCTION,
'LIB_VERSION': VERSION,
'AOT': IS_PRODUCTION
2016-08-28 21:46:10 +03:00
}),
new ForkCheckerPlugin()
],
}