gh-board/webpack.config.js

66 lines
2.5 KiB
JavaScript
Raw Normal View History

2015-06-07 21:08:05 +00:00
var path = require("path");
var webpack = require('webpack');
2015-09-11 04:04:31 +00:00
var ExtractTextPlugin = require('extract-text-webpack-plugin');
2015-09-28 08:54:51 +00:00
var isBuild = process.env['NODE_ENV'] === 'production';
2015-09-11 04:04:31 +00:00
var config = {
2015-06-07 21:08:05 +00:00
// devtool: '#eval-source-map',
2016-01-02 19:04:54 +00:00
devtool: 'source-map',
2015-06-07 21:08:05 +00:00
context: path.resolve(__dirname),
entry: [
2015-09-11 04:04:31 +00:00
// The following is added when `isBuild = falsy`
// 'webpack-dev-server/client?http://0.0.0.0:8080', // WebpackDevServer host and port
//'webpack/hot/only-dev-server',
'./style/index.js',
'./src/index.js'
2015-06-07 21:08:05 +00:00
],
output: {
path: __dirname + '/dist',
2015-09-25 01:06:14 +00:00
publicPath: './dist/', // gh-pages needs this to have a '.' for bundles
2015-09-11 04:04:31 +00:00
filename: 'bundle.js'
2015-06-07 21:08:05 +00:00
},
2015-09-11 04:04:31 +00:00
plugins: [
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('app.css')
],
2015-06-07 21:08:05 +00:00
module: {
preLoaders: [
2016-01-26 19:51:35 +00:00
{ test: /\.jsx?$/, loader: 'eslint-loader', exclude: [/node_modules|gantt-chart.*/, /octokat\.js/] },
2015-06-07 21:08:05 +00:00
],
loaders: [
2016-01-26 19:51:35 +00:00
{ test: /\.jsx?$/, loader: 'babel', exclude: [/node_modules/, /puzzle-script/, /octokat\.js/], query: { presets: ['react', 'es2015']} },
{ test: /\.json$/, loader: 'json-loader'},
2015-09-11 04:04:31 +00:00
{ test: /\.less$/, loader: ExtractTextPlugin.extract('css!less') },
{ test: /\.(png|jpg|svg)/, loader: 'file-loader?name=[name].[ext]'},
{ test: /\.(woff|woff2|eot|ttf)/, loader: "url-loader?limit=30000&name=[name]-[hash].[ext]" }
2015-06-07 21:08:05 +00:00
]
},
resolve: {
extensions: ['', '.js', '.jsx', '.json'],
2015-06-07 21:08:05 +00:00
alias: {
xmlhttprequest: path.join(__dirname, '/src/hacks/xmlhttprequest-filler.js'),
fs: path.join(__dirname, '/src/hacks/mermaid-stubs.js'),
proxyquire: path.join(__dirname, '/src/hacks/mermaid-stubs.js'),
rewire: path.join(__dirname, '/src/hacks/mermaid-stubs.js'),
'mock-browser': path.join(__dirname, '/src/hacks/mermaid-stubs.js')
2015-06-07 21:08:05 +00:00
},
},
2015-09-11 04:04:31 +00:00
devServer: {
// hot: true // Added when `isBuild = falsy`
}
2015-06-07 21:08:05 +00:00
};
2015-09-11 04:04:31 +00:00
2015-09-28 08:54:51 +00:00
if (isBuild) {
// Remove React warnings and whatnot
config.plugins.unshift(new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify('production') } }));
} else {
2015-09-14 07:16:25 +00:00
config.debug = true;
2015-09-25 01:06:14 +00:00
config.output.publicPath = '/dist/'; // Dev server needs this to not have a dot.
// config.entry.unshift('webpack/hot/only-dev-server');
2015-09-11 04:04:31 +00:00
config.entry.unshift('webpack-dev-server/client?http://0.0.0.0:8080');
config.devServer.hotComponents = true;
}
module.exports = config;