forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.production.config.js
33 lines (29 loc) · 1.06 KB
/
webpack.production.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var webpack = require("webpack");
var baseWebpackConfig = require("./frontend_build/baseWebpackConfig");
var productionWebpackConfig = baseWebpackConfig;
var publicPath = "/webpack-dist-optimized/"
if(process.env.NODE_ENV == 'production'){
var yaml = require('js-yaml');
var fs = require('fs');
try {
var doc = yaml.safeLoad(fs.readFileSync(__dirname + '/config/canvas_cdn.yml', 'utf8'));
var cdnHost = doc.production.host
if(cdnHost !== undefined && cdnHost !== null){
publicPath = cdnHost + "/dist" + publicPath;
console.log(publicPath);
}else{
console.log("NO CDN HOST, USING LOCAL ASSETS");
}
} catch (e) {
console.log("NO CDN FILE, USING LOCAL ASSETS");
}
}
productionWebpackConfig.devtool = undefined;
productionWebpackConfig.output.path = __dirname + '/public/webpack-dist-optimized';
productionWebpackConfig.output.publicPath = publicPath;
productionWebpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
mangle: false,
comments: false
}));
module.exports = productionWebpackConfig;