Created
October 20, 2014 22:15
-
-
Save shripadk/e61aa95a9758287e0e97 to your computer and use it in GitHub Desktop.
webpack node api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
var webpack = require('webpack'); | |
var WebPackDevServer = require('webpack-dev-server'); | |
var uglify = new webpack.optimize.UglifyJsPlugin(); | |
var config = [ | |
{ | |
entry: ['./src/main.js'], | |
output: { | |
path: path.join(process.cwd(), 'public'), | |
filename: '[name].js', | |
libraryTarget: 'umd' | |
}, | |
module: { | |
loaders: [ | |
{ test: /\.js$/, loader: 'jsx-loader?harmony' }, | |
{ test: /\.scss$/, loader: 'style!css!sass?outputStyle=expanded' } | |
] | |
}, | |
// plugins: [uglify] | |
} | |
]; | |
var callback = function(err, stats) { | |
console.log(stats.toString({colors: true})); | |
}; | |
if(process.env.NODE_ENV === 'production') { | |
webpack(config, callback); | |
return; | |
} | |
var server = new WebPackDevServer(webpack(config), { | |
publicPath: '/public/', | |
stats: { colors: true } | |
}); | |
server.listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment