namesny-com/webpack.prod.config.js

71 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-07-15 14:52:09 +00:00
const { resolve, join } = require('path')
const webpack = require('webpack')
const config = {
context: resolve(__dirname, 'src'),
entry: {
bundle: [
'./app-client.js'
]
},
output: {
path: resolve(__dirname, 'public/static'),
filename: '[name].js',
publicPath: '/static/'
},
module: {
rules: [
{
test: /\.js$/,
use: [
'babel-loader'
],
exclude: '/node_modules/'
},
{
test: /\.css$/,
2017-07-15 14:58:05 +00:00
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
localIdentName: '[name]__[local]___[hash:base64:5]'
2017-07-15 14:52:09 +00:00
}
2017-07-15 14:58:05 +00:00
},
{
loader: 'postcss-loader'
}
]
},
{test: /\.scss$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "sass-loader" // compiles Sass to CSS
}]
},
{
test: /\.(png|jpg)$/,
exclude: /node_modules/,
loader: 'url-loader'
},
2017-07-15 14:52:09 +00:00
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module) {
// this assumes your vendor imports exist in the node_modules directory
return module.context && module.context.indexOf('node_modules') !== -1
}
})
]
}
module.exports = config