1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- const path = require('path')
- const webpack = require('webpack')
- const vueConfig = require('./vue-loader.config')
- const ExtractTextPlugin = require('extract-text-webpack-plugin')
- const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
- const isProd = process.env.NODE_ENV === 'production'
- module.exports = {
- devtool: isProd ?
- false :
- '#cheap-module-source-map',
- output: {
- path: path.resolve(__dirname, '../dist'),
- publicPath: '/dist/',
- filename: '[name].[chunkhash].js'
- },
- resolve: {
- alias: {
- 'public': path.resolve(__dirname, '../public'),
- "lib": path.resolve(__dirname, '../src/util/lib.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: /\.(png|jpg|gif|svg|woff|eot|ttf)$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- name: '[name].[ext]?[hash]'
- }
- },
- {
- test: /\.css$/,
- use: isProd ?
- ExtractTextPlugin.extract({
- use: 'css-loader?minimize',
- fallback: 'vue-style-loader'
- }) :
- ['vue-style-loader', 'css-loader']
- },
- {
- test: /\.scss$/,
- use: isProd ?
- ExtractTextPlugin.extract({
- use: 'sass-loader?minimize',
- fallback: 'vue-style-loader'
- }) :
- ['vue-style-loader', 'sass-loader']
- }
- ]
- },
- performance: {
- maxEntrypointSize: 300000,
- hints: isProd ? 'warning' : false
- },
- plugins: isProd ?
- [
- new webpack.optimize.UglifyJsPlugin({
- compress: {
- warnings: false
- }
- }),
- new webpack.optimize.ModuleConcatenationPlugin(),
- new ExtractTextPlugin({
- filename: 'common.[chunkhash].css'
- })
- ] :
- [
- new FriendlyErrorsPlugin()
- ]
- }
|