Created
August 12, 2017 21:06
-
-
Save cristijora/f73edfbc335c7936d1d28698951561da 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' | |
} | |
] | |
}, | |
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