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");
|
2015-11-26 05:35:13 +03:00
|
|
|
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");
|
2015-11-26 05:35:13 +03:00
|
|
|
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();
|
2015-11-28 10:48:48 +03:00
|
|
|
var publicPath = config._config.output.publicPath;
|
2015-11-27 10:50:37 +03:00
|
|
|
// 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: "/",
|
2015-11-26 05:35:13 +03:00
|
|
|
},
|
|
|
|
resolveLoader: {
|
|
|
|
root: path.join(__dirname, "node_modules"),
|
|
|
|
modulesDirectories: ['./'],
|
|
|
|
},
|
|
|
|
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'),
|
2015-11-28 10:48:48 +03:00
|
|
|
'pypyjs': '../playground/graphene-js/pypyjs',
|
2015-11-27 10:50:37 +03:00
|
|
|
'playground-page': (env != "static")?'../playground/page':'../pages/_empty',
|
|
|
|
'playground-wrapper': (env == "develop")?'../playground/page':'../playground/wrapper',
|
2015-11-26 05:35:13 +03:00
|
|
|
},
|
|
|
|
modulesDirectories: ['./']
|
2015-11-21 21:33:29 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
if (IS_STATIC) {
|
|
|
|
config.plugin('extract-css', ExtractTextPlugin, ["app.css"]);
|
|
|
|
}
|
2015-11-26 05:35:13 +03:00
|
|
|
config.plugin('static', CopyWebpackPlugin, [[{ from: '../static'}]]);
|
2015-11-28 10:48:48 +03:00
|
|
|
config.plugin('define-env', webpack.DefinePlugin, [{
|
|
|
|
"ENV": JSON.stringify(env),
|
|
|
|
"PUBLIC_PATH": JSON.stringify(publicPath),
|
|
|
|
}]);
|
2015-11-27 10:50:37 +03:00
|
|
|
// if (env != "static") {
|
|
|
|
// config.plugin('commons', webpack.optimize.CommonsChunkPlugin, ["commons.js"]);
|
|
|
|
// }
|
2015-11-26 05:35:13 +03:00
|
|
|
|
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
|
|
|
|
});
|
2015-11-26 05:35:13 +03:00
|
|
|
config.removeLoader('png');
|
|
|
|
config.loader('png', function(cfg) {
|
|
|
|
cfg.test = /\.png$/;
|
2015-11-26 08:45:02 +03:00
|
|
|
cfg.loader = 'url-loader'
|
2015-11-26 05:35:13 +03:00
|
|
|
return cfg
|
|
|
|
})
|
2015-11-21 21:33:29 +03:00
|
|
|
return config;
|
|
|
|
};
|