|
| 1 | +const skeleton = require('./webpack-skeleton') |
| 2 | +const webpack = require('webpack') |
| 3 | +const path = require('path') |
| 4 | +const NodeTargetPlugin = require('webpack/lib/node/NodeTargetPlugin') |
| 5 | + |
| 6 | +var JsonpTemplatePlugin = webpack.JsonpTemplatePlugin |
| 7 | +var FunctionModulePlugin = require('webpack/lib/FunctionModulePlugin') |
| 8 | +var config = Object.assign({}, skeleton, { |
| 9 | + module: { |
| 10 | + loaders: [ |
| 11 | + { |
| 12 | + test: /(\.js|\.jsx)?$/, |
| 13 | + exclude: /(node_modules|bower_components)/, |
| 14 | + loader: 'babel' |
| 15 | + }, |
| 16 | + { |
| 17 | + test: /\.styl?$/, |
| 18 | + exclude: /(node_modules|bower_components)/, |
| 19 | + loader: 'style-loader!css-loader!stylus-loader' |
| 20 | + } |
| 21 | + ] |
| 22 | + }, |
| 23 | + output: { |
| 24 | + path: path.join(__dirname, 'compiled'), |
| 25 | + filename: '[name].js', |
| 26 | + libraryTarget: 'commonjs2', |
| 27 | + sourceMapFilename: '[name].map', |
| 28 | + publicPath: 'http://localhost:8080/assets/' |
| 29 | + }, |
| 30 | + plugins: [ |
| 31 | + new webpack.NoErrorsPlugin(), |
| 32 | + new NodeTargetPlugin(), |
| 33 | + new webpack.optimize.OccurenceOrderPlugin(), |
| 34 | + new webpack.DefinePlugin({ |
| 35 | + 'process.env': { |
| 36 | + 'NODE_ENV': JSON.stringify('production'), |
| 37 | + 'BABEL_ENV': JSON.stringify('production') |
| 38 | + } |
| 39 | + }), |
| 40 | + new webpack.optimize.UglifyJsPlugin({ |
| 41 | + compressor: { |
| 42 | + warnings: false |
| 43 | + } |
| 44 | + }) |
| 45 | + ] |
| 46 | +}) |
| 47 | + |
| 48 | +config.target = function renderer (compiler) { |
| 49 | + compiler.apply( |
| 50 | + new JsonpTemplatePlugin(config.output), |
| 51 | + new FunctionModulePlugin(config.output) |
| 52 | + ) |
| 53 | +} |
| 54 | + |
| 55 | +module.exports = config |
0 commit comments