* improvement: re-enable and improve Models jump-to-path
* preserve function names
without this, a recent Swagger Client change breaks
cc: f8fccb4510
* bump swagger-client to 3.8.7
* bump selenium-server-standalone-jar
* lock down `selenium-server-standalone-jar` version
* v3.17.2
* parallelize build command
* use npm-run-all for compound scripts
* rebuild dist
156 lines
3.5 KiB
JavaScript
156 lines
3.5 KiB
JavaScript
var path = require("path")
|
|
|
|
var webpack = require("webpack")
|
|
var ExtractTextPlugin = require("extract-text-webpack-plugin")
|
|
const CopyWebpackPlugin = require("copy-webpack-plugin")
|
|
const UglifyJsPlugin = require("uglifyjs-webpack-plugin")
|
|
var deepExtend = require("deep-extend")
|
|
const {gitDescribeSync} = require("git-describe")
|
|
const os = require("os")
|
|
|
|
var pkg = require("./package.json")
|
|
|
|
let gitInfo
|
|
|
|
try {
|
|
gitInfo = gitDescribeSync(__dirname)
|
|
} catch(e) {
|
|
gitInfo = {
|
|
hash: "noGit",
|
|
dirty: false
|
|
}
|
|
}
|
|
|
|
var commonRules = [
|
|
{ test: /\.(js(x)?)(\?.*)?$/,
|
|
use: [{
|
|
loader: "babel-loader",
|
|
options: {
|
|
retainLines: true
|
|
}
|
|
}],
|
|
include: [
|
|
path.join(__dirname, "src"),
|
|
path.join(__dirname, "node_modules", "object-assign-deep"),
|
|
]
|
|
},
|
|
{ test: /\.(txt|yaml)(\?.*)?$/,
|
|
loader: "raw-loader" },
|
|
{ test: /\.(png|jpg|jpeg|gif|svg)(\?.*)?$/,
|
|
loader: "url-loader?limit=10000" },
|
|
{ test: /\.(woff|woff2)(\?.*)?$/,
|
|
loader: "url-loader?limit=100000" },
|
|
{ test: /\.(ttf|eot)(\?.*)?$/,
|
|
loader: "file-loader" }
|
|
]
|
|
|
|
module.exports = function(rules, options) {
|
|
|
|
// Special options, that have logic in this file
|
|
// ...with defaults
|
|
var specialOptions = deepExtend({}, {
|
|
hot: false,
|
|
separateStylesheets: true,
|
|
minimize: false,
|
|
mangle: false,
|
|
longTermCaching: false,
|
|
sourcemaps: false,
|
|
}, options._special)
|
|
|
|
var plugins = []
|
|
|
|
if( specialOptions.separateStylesheets ) {
|
|
plugins.push(new ExtractTextPlugin({
|
|
filename: "[name].css" + (specialOptions.longTermCaching ? "?[contenthash]" : ""),
|
|
allChunks: true
|
|
}))
|
|
}
|
|
|
|
if( specialOptions.minimize ) { // production mode
|
|
|
|
plugins.push(
|
|
new UglifyJsPlugin({
|
|
uglifyOptions: {
|
|
mangle: specialOptions.mangle,
|
|
beautify: !specialOptions.mangle,
|
|
keep_fnames: true
|
|
},
|
|
sourceMap: true,
|
|
}),
|
|
new webpack.LoaderOptionsPlugin({
|
|
options: {
|
|
context: __dirname
|
|
}
|
|
})
|
|
)
|
|
|
|
plugins.push( new webpack.NoEmitOnErrorsPlugin())
|
|
|
|
} else { // development mode
|
|
plugins.push(new CopyWebpackPlugin([ { from: "test/e2e/specs", to: "test-specs" } ]))
|
|
}
|
|
|
|
plugins.push(
|
|
new webpack.DefinePlugin({
|
|
"process.env": {
|
|
NODE_ENV: specialOptions.minimize ? JSON.stringify("production") : null,
|
|
WEBPACK_INLINE_STYLES: !specialOptions.separateStylesheets
|
|
},
|
|
"buildInfo": JSON.stringify({
|
|
PACKAGE_VERSION: (pkg.version),
|
|
GIT_COMMIT: gitInfo.hash,
|
|
GIT_DIRTY: gitInfo.dirty,
|
|
HOSTNAME: os.hostname(),
|
|
BUILD_TIME: new Date().toUTCString()
|
|
})
|
|
}))
|
|
|
|
delete options._special
|
|
|
|
var completeConfig = deepExtend({
|
|
entry: {},
|
|
|
|
output: {
|
|
path: path.join(__dirname, "dist"),
|
|
publicPath: "/",
|
|
filename: "[name].js",
|
|
chunkFilename: "[name].js"
|
|
},
|
|
|
|
target: "web",
|
|
|
|
// yaml-js has a reference to `fs`, this is a workaround
|
|
node: {
|
|
fs: "empty"
|
|
},
|
|
|
|
module: {
|
|
rules: commonRules.concat(rules),
|
|
},
|
|
|
|
resolveLoader: {
|
|
modules: [path.join(__dirname, "node_modules")],
|
|
},
|
|
|
|
externals: {
|
|
"buffertools": true // json-react-schema/deeper depends on buffertools, which fails.
|
|
},
|
|
|
|
resolve: {
|
|
modules: [
|
|
path.join(__dirname, "./src"),
|
|
"node_modules"
|
|
],
|
|
extensions: [".web.js", ".js", ".jsx", ".json", ".less"],
|
|
alias: {}
|
|
},
|
|
|
|
devtool: specialOptions.sourcemaps ? "nosource-source-map" : false,
|
|
|
|
plugins,
|
|
|
|
}, options)
|
|
|
|
return completeConfig
|
|
}
|