-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
69 lines (66 loc) · 1.96 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const webpack = require('webpack');
const { addPlugins, createConfig, defineConstants, resolveAliases, env, entryPoint, setOutput, sourceMaps } = require('@webpack-blocks/webpack2');
const babel = require('@webpack-blocks/babel6');
const devServer = require('@webpack-blocks/dev-server2');
const postcss = require('@webpack-blocks/postcss');
const vue = require('./build/webpack-blocks/vue');
const eslint = require('./build/webpack-blocks/eslint');
const autoprefixer = require('autoprefixer');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = createConfig([
entryPoint('./src/index.js'),
setOutput('./dist/bundle.[hash].js'),
resolveAliases({ '@': path.resolve('./src') }),
babel(),
postcss([
autoprefixer({ browsers: ['> 1%', 'last 2 versions'] }),
]),
defineConstants({
'process.env.NODE_ENV': process.env.NODE_ENV || 'development',
}),
addPlugins([
new HtmlWebpackPlugin({ template: './src/index.html' }),
]),
env('development', [
vue(),
eslint(),
addPlugins([
new webpack.NamedModulesPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new FriendlyErrorsPlugin(),
]),
devServer({
host: '0.0.0.0',
disableHostCheck: true,
}),
sourceMaps(),
]),
env('production', [
vue({
loaders: {
css: ExtractTextPlugin.extract({
use: 'css-loader!postcss-loader',
fallback: 'vue-style-loader',
}),
},
}),
eslint(),
sourceMaps('source-map'),
addPlugins([
new ExtractTextPlugin('css/style.[hash:6].css'),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
sourceMap: true,
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
}),
]),
]),
]);