2017-07-31 16:40:37 +00:00
|
|
|
const webpack = require('webpack');
|
|
|
|
const path = require('path');
|
2016-09-27 18:06:28 +00:00
|
|
|
|
2017-07-31 16:40:37 +00:00
|
|
|
|
|
|
|
let config = {
|
2017-04-05 21:14:08 +00:00
|
|
|
entry: "./static/js/main.ts",
|
2016-09-27 18:06:28 +00:00
|
|
|
output: {
|
2017-01-24 22:05:06 +00:00
|
|
|
path: path.resolve(__dirname, "static/build"),
|
2017-08-01 17:28:24 +00:00
|
|
|
publicPath: "/static/build/",
|
|
|
|
filename: '[name]-quay-frontend.bundle.js',
|
|
|
|
chunkFilename: '[name]-quay-frontend.chunk.js'
|
2016-09-27 18:06:28 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
2017-07-31 16:40:37 +00:00
|
|
|
extensions: [".ts", ".js"],
|
2016-09-27 18:06:28 +00:00
|
|
|
},
|
2017-05-21 09:10:11 +00:00
|
|
|
// Use global variables to maintain compatibility with non-Webpack components
|
2017-01-19 08:53:38 +00:00
|
|
|
externals: {
|
2017-02-06 22:05:19 +00:00
|
|
|
angular: "angular",
|
2017-05-21 09:10:11 +00:00
|
|
|
jquery: "$",
|
2017-08-02 15:26:36 +00:00
|
|
|
moment: "moment",
|
|
|
|
"raven-js": "Raven",
|
2017-01-19 08:53:38 +00:00
|
|
|
},
|
2016-09-27 18:06:28 +00:00
|
|
|
module: {
|
2017-02-06 22:05:19 +00:00
|
|
|
rules: [
|
2016-09-27 18:06:28 +00:00
|
|
|
{
|
2017-07-13 14:12:46 +00:00
|
|
|
test: /\.ts$/,
|
2017-05-25 04:42:06 +00:00
|
|
|
use: ["ts-loader"],
|
2016-09-27 18:06:28 +00:00
|
|
|
exclude: /node_modules/
|
2016-11-02 18:15:52 +00:00
|
|
|
},
|
2017-01-18 23:46:37 +00:00
|
|
|
{
|
2017-06-07 19:54:43 +00:00
|
|
|
test: /\.css$/,
|
2017-02-06 22:05:19 +00:00
|
|
|
use: [
|
|
|
|
"style-loader",
|
2017-05-21 09:10:11 +00:00
|
|
|
"css-loader?minimize=true",
|
2017-02-06 22:05:19 +00:00
|
|
|
],
|
2017-01-19 08:53:38 +00:00
|
|
|
},
|
2017-05-21 09:10:11 +00:00
|
|
|
{
|
|
|
|
test: /\.html$/,
|
|
|
|
use: [
|
|
|
|
'ngtemplate-loader?relativeTo=' + (path.resolve(__dirname)),
|
|
|
|
'html-loader',
|
|
|
|
]
|
2017-05-25 04:42:06 +00:00
|
|
|
},
|
2016-09-27 18:06:28 +00:00
|
|
|
]
|
2017-01-18 23:46:37 +00:00
|
|
|
},
|
2017-05-21 09:10:11 +00:00
|
|
|
plugins: [
|
|
|
|
// Replace references to global variables with associated modules
|
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
FileSaver: 'file-saver',
|
|
|
|
angular: "angular",
|
|
|
|
$: "jquery",
|
2017-08-02 15:26:36 +00:00
|
|
|
moment: "moment",
|
2017-05-21 09:10:11 +00:00
|
|
|
}),
|
2017-08-02 15:26:36 +00:00
|
|
|
// Restrict the extra locales that moment.js can load; en is always included
|
|
|
|
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/),
|
2017-05-21 09:10:11 +00:00
|
|
|
],
|
|
|
|
devtool: "cheap-module-source-map",
|
2016-09-27 18:06:28 +00:00
|
|
|
};
|
|
|
|
|
2017-05-21 09:10:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Production settings
|
|
|
|
*/
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
2017-08-01 17:28:24 +00:00
|
|
|
config.plugins.concat([
|
2017-05-21 09:10:11 +00:00
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
sourceMap: true,
|
|
|
|
// Disable mangle to prevent AngularJS errors
|
|
|
|
mangle: false
|
2017-08-01 17:28:24 +00:00
|
|
|
}),
|
|
|
|
new webpack.optimize.CommonsChunkPlugin({name: 'common'}),
|
|
|
|
]);
|
|
|
|
config.output.filename = '[name]-quay-frontend-[hash].bundle.js';
|
2017-05-21 09:10:11 +00:00
|
|
|
}
|
|
|
|
|
2016-09-27 18:06:28 +00:00
|
|
|
module.exports = config;
|