graphene/docs/gatsby.config.js

71 lines
2.2 KiB
JavaScript
Raw Normal View History

2015-11-21 21:33:29 +03:00
var nib = require("nib");
var jeet = require("jeet");
2015-11-26 02:25:03 +03:00
var rupture = require("rupture");
var path = require("path");
2015-11-21 21:33:29 +03:00
var ExtractTextPlugin = require("extract-text-webpack-plugin");
2015-11-27 10:50:37 +03:00
var webpack = require("webpack");
var CopyWebpackPlugin = require('copy-webpack-plugin');
2015-11-21 21:33:29 +03:00
module.exports = function(config, env) {
var IS_STATIC = env === 'static';
2015-11-27 10:50:37 +03:00
var entry = config._config.entry.slice();
// var output = config._config.output;
// output.filename = "[name].js";
config._config.entry = {
bundle: entry,
};
2015-11-21 21:33:29 +03:00
config.merge({
2015-11-27 10:50:37 +03:00
stylus: {
use: [nib(), jeet(), rupture()]
},
output: {
filename: "[name].js",
publicPath: "/",
},
resolveLoader: {
root: path.join(__dirname, "node_modules"),
modulesDirectories: ['./'],
alias: {
'copy': 'file-loader?name=[path][name].[ext]&context=./static',
}
},
resolve: {
root: path.join(__dirname, "node_modules"),
alias: {
'original-react': path.join(__dirname, "node_modules", "react"),
'react/lib': path.join(__dirname, "node_modules", "react", "lib"),
2015-11-27 10:50:37 +03:00
'react': path.join(__dirname, 'patched-react.js'),
'playground-page': (env != "static")?'../playground/page':'../pages/_empty',
'playground-wrapper': (env == "develop")?'../playground/page':'../playground/wrapper',
},
modulesDirectories: ['./']
2015-11-21 21:33:29 +03:00
}
});
if (IS_STATIC) {
config.plugin('extract-css', ExtractTextPlugin, ["app.css"]);
}
config.plugin('static', CopyWebpackPlugin, [[{ from: '../static'}]]);
2015-11-27 10:50:37 +03:00
config.plugin('define-env', webpack.DefinePlugin, [{"ENV": JSON.stringify(env)}]);
// if (env != "static") {
// config.plugin('commons', webpack.optimize.CommonsChunkPlugin, ["commons.js"]);
// }
2015-11-21 21:33:29 +03:00
config.loader('stylus', function(cfg) {
cfg.test = /\.styl$/;
if (IS_STATIC) {
cfg.loader = ExtractTextPlugin.extract('style-loader', 'css-loader!stylus-loader', { allChunks: true });
}
else {
cfg.loader = 'style-loader!css-loader!stylus-loader';
}
return cfg
});
config.removeLoader('png');
config.loader('png', function(cfg) {
cfg.test = /\.png$/;
2015-11-26 08:45:02 +03:00
cfg.loader = 'url-loader'
return cfg
})
2015-11-21 21:33:29 +03:00
return config;
};