vue-docs
Version:
106 lines (102 loc) • 3.17 kB
JavaScript
import path from 'path'
import webpack from 'webpack'
import autoprefixer from 'autoprefixer'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import { serviceWorkerConfig } from './config'
let config = {
entry: {
main: [path.resolve(__dirname, 'static/entry.js')],
vendors: ['vue', 'vue-router']
},
output: {
publicPath: '',
path: path.resolve(__dirname, 'dist'),
filename: 'js/[name].[hash:7].js',
chunkFilename: 'js/[id].[hash:7].js'
},
resolve: {
extensions: ['', '.js', '.css', '.vue', '.json'],
alias: {
'vue': 'vue/dist/vue.runtime.common.js',
'docs': path.resolve(__dirname, 'static/docs'),
'pages': path.resolve(__dirname, 'static/pages'),
'components': path.resolve(__dirname, 'static/components')
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"',
[serviceWorkerConfig.ENABLE_KEY]: process.env[serviceWorkerConfig.ENABLE_KEY]
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new ExtractTextPlugin('css/[name].[hash:7].css'),
new webpack.optimize.CommonsChunkPlugin('vendors', 'js/vendors.[hash:7].js'),
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve(__dirname, 'index.html')
})
],
module: {
loaders: [{
test: /\.vue$/,
loader: 'vue'
}, {
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css')
}, {
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url',
query: {
limit: 1,
name: 'img/[name].[hash:7].[ext]'
}
}, {
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url',
query: {
limit: 1,
name: 'fonts/[name].[hash:7].[ext]'
}
}]
},
babel: {
presets: [[
"env",
{
"targets": [
"last 5 versions"
],
"loose": true
}
], 'stage-0'],
plugins: ['transform-vue-jsx', 'transform-runtime']
},
vue: {
loaders: {
css: ExtractTextPlugin.extract('vue-style-loader', 'css-loader')
},
postcss: [
autoprefixer({ browsers: ['last 7 versions'] })
]
}
}
if (process.env[serviceWorkerConfig.ENABLE_KEY]) {
let ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin')
config.plugins.push(new ServiceWorkerWebpackPlugin({
entry: path.join(__dirname, 'sw.js'),
excludes: serviceWorkerConfig.excludes
}))
}
module.exports = config