1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-02-24 09:33:19 +01:00
BezierInfo-2/webpack.config.js

100 lines
2.2 KiB
JavaScript
Raw Normal View History

2015-12-20 15:19:50 -08:00
var webpack = require('webpack');
2016-01-22 17:43:40 -08:00
var path = require('path');
var fs = require('fs');
// see http://jlongster.com/Backend-Apps-with-Webpack--Part-I
var externals = false;
2015-12-20 15:19:50 -08:00
2016-01-09 18:39:09 -08:00
// Bundle entry point
2015-12-20 15:19:50 -08:00
var entry = ['./components/App.jsx'];
2016-01-09 18:39:09 -08:00
2016-01-22 17:43:40 -08:00
// Bundle target
var target = "web";
// Bundle output
var output = {
path: __dirname,
filename: 'article.js'
};
2016-01-09 18:39:09 -08:00
// Necessary webpack loaders for converting our content:
var webpackLoaders = [
'babel-loader',
2016-01-12 13:39:35 -08:00
'eslint',
2016-01-09 18:39:09 -08:00
__dirname + '/lib/latex-loader',
__dirname + '/lib/pre-loader',
__dirname + '/lib/p-loader'
];
2016-01-09 23:31:52 -08:00
var plugins = [];
2016-01-12 13:39:35 -08:00
// Dev mode: make certain concessions to speed up dev work.
if(process.argv.indexOf("--prod") === -1 && process.argv.indexOf("--lint")) {
2016-01-09 18:39:09 -08:00
// use the webpack hot Reload server:
2015-12-20 15:19:50 -08:00
entry.push('webpack/hot/dev-server');
2016-01-12 13:39:35 -08:00
// allow code in textareas when in dev mode:
2016-01-09 18:39:09 -08:00
webpackLoaders.push(__dirname + '/lib/textarea-loader');
2015-12-20 15:19:50 -08:00
}
2016-01-09 23:31:52 -08:00
// Prod mode: make sure to minify the bundle
2016-01-12 13:39:35 -08:00
else if(process.argv.indexOf("--prod") > -1) {
plugins.push(new webpack.optimize.UglifyJsPlugin());
}
2016-01-09 23:31:52 -08:00
2016-01-22 17:43:40 -08:00
// However, do we want one full page, or single pages with react-router?
if(process.argv.indexOf("--singles") !== -1 ) {
entry = ['./lib/site/routemap.js'];
target = "node";
output = {
path: output.path + '/pages',
filename: "routemap.js",
library: "routemap",
libraryTarget: "commonjs2"
};
console.log("\n","marking node_modules as external","\n");
externals = {};
fs.readdirSync('node_modules')
.filter(function(x) { return ['.bin'].indexOf(x) === -1; })
.forEach(function(mod) { externals[mod] = 'commonjs ' + mod; });
plugins.pop();
}
2016-01-09 18:39:09 -08:00
// And the final config that webpack will read in.
2015-12-20 15:19:50 -08:00
module.exports = {
entry: entry,
2016-01-22 17:43:40 -08:00
target: target,
output: output,
2015-12-20 15:19:50 -08:00
module: {
loaders: [
2016-01-22 17:43:40 -08:00
{
test: /\.(png|gif)$/,
loader: "file?name=images/packed/[hash].[ext]"
},
{
test: /\.less$/,
loader: "style!css!less"
},
{
test: /\.json$/,
loader: "json"
},
2015-12-20 15:19:50 -08:00
{
test: /.jsx?$/,
2016-01-22 17:43:40 -08:00
include: [
/components/,
/lib.site/
],
2016-01-09 18:39:09 -08:00
loaders: webpackLoaders
2015-12-20 15:19:50 -08:00
}
]
},
2016-01-12 13:39:35 -08:00
plugins: plugins,
eslint: {
configFile: __dirname + '/.eslintrc'
2016-01-22 17:43:40 -08:00
},
externals: externals
2015-12-23 08:08:32 -08:00
};