Skip to content

Instantly share code, notes, and snippets.

@petervmeijgaard
Last active August 9, 2016 15:30
Show Gist options
  • Save petervmeijgaard/b2e7bb04e100bc9f7da40565d48d6cbe to your computer and use it in GitHub Desktop.
Save petervmeijgaard/b2e7bb04e100bc9f7da40565d48d6cbe to your computer and use it in GitHub Desktop.
webpack.config.js
var webpack = require('webpack')
var path = require('path')
module.exports = {
entry: './src/index.js',
output: {
path: './dist/',
filename: 'index.js',
library: 'VueComponents',
libraryTarget: 'umd'
},
resolve: {
modulesDirectories: ['node_modules', './src'],
},
module: {
loaders: [
{ test: /\.vue$/, loader: 'vue' },
{
test: /\.js$/,
exclude: /node_modules|vue\/src|vue-router\/|vue-loader\/|vue-hot-reload-api\//,
loader: 'babel'
},
{
test: /\.css$/, loader: "style-loader!css-loader"
},
{
test: /\.styl/, loader: "style-loader!css-loader!stylus-loader"
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url',
query: {
limit: 10000,
name: 'img/[name].[ext]'
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url',
query: {
limit: 10000,
name: 'fonts/[name].[ext]'
}
}
]
},
babel: {
presets: ['es2015'],
plugins: ['transform-runtime']
},
devtool: 'source-map'
};
if (process.env.NODE_ENV === 'production') {
module.exports.plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
drop_console: true,
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment