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-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';
|
|
|
|
config.merge({
|
|
|
|
stylus: {
|
2015-11-26 02:25:03 +03:00
|
|
|
use: [nib(), jeet(), rupture()]
|
2015-11-26 05:35:13 +03:00
|
|
|
},
|
|
|
|
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"),
|
|
|
|
'react': path.join(__dirname, 'patched-react.js')
|
|
|
|
},
|
|
|
|
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-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$/;
|
|
|
|
cfg.loader = 'file-loader'
|
|
|
|
return cfg
|
|
|
|
})
|
2015-11-21 21:33:29 +03:00
|
|
|
return config;
|
|
|
|
};
|