2017-07-24 08:45:00 +00:00
|
|
|
const path = require('path')
|
2017-07-26 21:46:30 +00:00
|
|
|
const chalk = require('chalk')
|
2017-07-24 08:45:00 +00:00
|
|
|
const webpack = require('webpack')
|
|
|
|
const vueConfig = require('./vue-loader.config')
|
|
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
|
|
|
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
|
2017-07-26 21:46:30 +00:00
|
|
|
const ProgressBarPlugin = require('progress-bar-webpack-plugin')
|
2017-07-24 08:45:00 +00:00
|
|
|
|
2017-07-24 10:33:00 +00:00
|
|
|
const isDev = process.env.NODE_ENV === 'development'
|
2017-07-24 08:45:00 +00:00
|
|
|
const resolve = (file) => path.resolve(__dirname, file)
|
|
|
|
|
|
|
|
module.exports = {
|
2017-07-24 10:33:00 +00:00
|
|
|
devtool: !isDev
|
2017-07-24 08:45:00 +00:00
|
|
|
? false
|
|
|
|
: '#cheap-module-source-map',
|
|
|
|
output: {
|
|
|
|
path: resolve('../public'),
|
|
|
|
publicPath: '/public/',
|
|
|
|
filename: '[name].[chunkhash].js'
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['*', '.js', '.json', '.vue'],
|
|
|
|
alias: {
|
|
|
|
'assets': resolve('../assets'),
|
|
|
|
'components': resolve('../components'),
|
|
|
|
'examples': resolve('../pages/examples'),
|
|
|
|
'layouts': resolve('../layouts'),
|
|
|
|
'mixins': resolve('../mixins'),
|
|
|
|
'pages': resolve('../pages'),
|
|
|
|
'public': resolve('../public'),
|
|
|
|
'router': resolve('../router'),
|
|
|
|
'static': resolve('../static'),
|
|
|
|
'store': resolve('../store'),
|
|
|
|
'vue$': 'vue/dist/vue.common.js'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
noParse: /es6-promise\.js$/, // avoid webpack shimming process
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.vue$/,
|
|
|
|
loader: 'vue-loader',
|
|
|
|
options: vueConfig
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
loader: 'babel-loader',
|
|
|
|
exclude: /node_modules/
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.styl$/,
|
|
|
|
loader: ['style-loader', 'css-loader', 'stylus-loader']
|
|
|
|
},
|
|
|
|
{
|
2017-08-26 22:01:49 +00:00
|
|
|
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
2017-07-24 08:45:00 +00:00
|
|
|
loader: 'url-loader',
|
|
|
|
query: {
|
|
|
|
limit: 10000,
|
|
|
|
name: 'img/[name].[hash:7].[ext]'
|
|
|
|
}
|
2017-08-26 22:01:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
|
|
|
loader: 'url-loader',
|
|
|
|
options: {
|
|
|
|
limit: 1000,
|
|
|
|
name: 'fonts/[name].[hash:7].[ext]'
|
|
|
|
}
|
2017-07-24 08:45:00 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
performance: {
|
|
|
|
maxEntrypointSize: 300000,
|
2017-07-24 10:33:00 +00:00
|
|
|
hints: !isDev ? 'warning' : false
|
2017-07-24 08:45:00 +00:00
|
|
|
},
|
2017-07-24 10:33:00 +00:00
|
|
|
plugins: !isDev
|
2017-07-24 08:45:00 +00:00
|
|
|
? [
|
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
compress: { warnings: false }
|
|
|
|
}),
|
|
|
|
new ExtractTextPlugin({
|
|
|
|
filename: 'common.[chunkhash].css'
|
2017-07-26 21:46:30 +00:00
|
|
|
}),
|
|
|
|
new ProgressBarPlugin({
|
|
|
|
format: chalk.cyan('> build') + ' [:bar] ' + chalk.green.bold(':percent') + ' (:elapsed seconds)',
|
|
|
|
clear: true
|
2017-07-24 08:45:00 +00:00
|
|
|
})
|
|
|
|
]
|
|
|
|
: [
|
|
|
|
new FriendlyErrorsPlugin()
|
|
|
|
]
|
|
|
|
}
|