Created
August 12, 2017 20:51
-
-
Save cristijora/ba77e4933ff12c4e3b26b6d4d40c2fd6 to your computer and use it in GitHub Desktop.
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 fs = require('fs') | |
var appBasePath = './Scripts/app/' | |
var jsEntries = {} | |
// We search for index.js files inside basePath folder and make those as entries | |
fs.readdirSync(appBasePath).forEach(function (name) { | |
var indexFile = appBasePath + name + '/index.js' | |
if (fs.existsSync(indexFile)) { | |
jsEntries[name] = indexFile | |
} | |
}) | |
module.exports = { | |
entry: jsEntries, | |
output: { | |
path: path.resolve(__dirname, './Scripts/bundle/'), | |
publicPath: '/Scripts/bundle/', | |
filename: '[name].js' | |
}, | |
resolve: { | |
extensions: ['.js', '.vue', '.json'], | |
alias: { | |
'vue$': 'vue/dist/vue.esm.js', | |
'@': path.join(__dirname, appBasePath) | |
} | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.vue$/, | |
loader: 'vue-loader' | |
}, | |
{ | |
test: /\.js$/, | |
loader: 'babel-loader', | |
exclude: /node_modules/ | |
}, | |
{ | |
test: /\.css$/, | |
loader: 'style-loader!css-loader' | |
}, | |
{ | |
test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/, | |
loader: 'file-loader' | |
}, | |
{ | |
test: /\.(png|jpe?g|gif|svg)(\?\S*)?$/, | |
loader: 'file-loader', | |
query: { | |
name: '[name].[ext]?[hash]' | |
} | |
} | |
] | |
}, | |
devServer: { | |
proxy: { | |
'*': { | |
target: 'http://localhost:5001', | |
changeOrigin: true | |
} | |
} | |
}, | |
devtool: '#eval-source-map' | |
} | |
if (process.env.NODE_ENV === 'production') { | |
module.exports.devtool = '#source-map' | |
// http://vue-loader.vuejs.org/en/workflow/production.html | |
module.exports.plugins = (module.exports.plugins || []).concat([ | |
new webpack.DefinePlugin({ | |
'process.env': { | |
NODE_ENV: '"production"' | |
} | |
}), | |
new webpack.optimize.UglifyJsPlugin({ | |
compress: { | |
warnings: false | |
} | |
}) | |
]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment