1 | 'use strict';
|
2 |
|
3 | var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
|
4 |
|
5 | var _defineProperty3 = _interopRequireDefault(_defineProperty2);
|
6 |
|
7 | var _path = require('path');
|
8 |
|
9 | var _path2 = _interopRequireDefault(_path);
|
10 |
|
11 | var _webpack = require('webpack');
|
12 |
|
13 | var _webpack2 = _interopRequireDefault(_webpack);
|
14 |
|
15 | var _autoprefixer = require('autoprefixer');
|
16 |
|
17 | var _autoprefixer2 = _interopRequireDefault(_autoprefixer);
|
18 |
|
19 | var _htmlWebpackPlugin = require('html-webpack-plugin');
|
20 |
|
21 | var _htmlWebpackPlugin2 = _interopRequireDefault(_htmlWebpackPlugin);
|
22 |
|
23 | var _extractTextWebpackPlugin = require('extract-text-webpack-plugin');
|
24 |
|
25 | var _extractTextWebpackPlugin2 = _interopRequireDefault(_extractTextWebpackPlugin);
|
26 |
|
27 | var _config = require('./config');
|
28 |
|
29 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
30 |
|
31 | var config = {
|
32 | entry: {
|
33 | main: [_path2.default.resolve(__dirname, 'static/entry.js')],
|
34 | vendors: ['vue', 'vue-router']
|
35 | },
|
36 | output: {
|
37 | publicPath: '',
|
38 | path: _path2.default.resolve(__dirname, 'dist'),
|
39 | filename: 'js/[name].[hash:7].js',
|
40 | chunkFilename: 'js/[id].[hash:7].js'
|
41 | },
|
42 | resolve: {
|
43 | extensions: ['', '.js', '.css', '.vue', '.json'],
|
44 | alias: {
|
45 | 'vue': 'vue/dist/vue.runtime.common.js',
|
46 | 'docs': _path2.default.resolve(__dirname, 'static/docs'),
|
47 | 'pages': _path2.default.resolve(__dirname, 'static/pages'),
|
48 | 'components': _path2.default.resolve(__dirname, 'static/components')
|
49 | }
|
50 | },
|
51 | plugins: [new _webpack2.default.DefinePlugin({
|
52 | 'process.env': (0, _defineProperty3.default)({
|
53 | NODE_ENV: '"production"'
|
54 | }, _config.serviceWorkerConfig.ENABLE_KEY, process.env[_config.serviceWorkerConfig.ENABLE_KEY])
|
55 | }), new _webpack2.default.optimize.UglifyJsPlugin({
|
56 | compress: {
|
57 | warnings: false
|
58 | }
|
59 | }), new _webpack2.default.optimize.OccurenceOrderPlugin(), new _extractTextWebpackPlugin2.default('css/[name].[hash:7].css'), new _webpack2.default.optimize.CommonsChunkPlugin('vendors', 'js/vendors.[hash:7].js'), new _htmlWebpackPlugin2.default({
|
60 | filename: 'index.html',
|
61 | template: _path2.default.resolve(__dirname, 'index.html')
|
62 | })],
|
63 | module: {
|
64 | loaders: [{
|
65 | test: /\.vue$/,
|
66 | loader: 'vue'
|
67 | }, {
|
68 | test: /\.js$/,
|
69 | loader: 'babel',
|
70 | exclude: /node_modules/
|
71 | }, {
|
72 | test: /\.css$/,
|
73 | loader: _extractTextWebpackPlugin2.default.extract('style', 'css')
|
74 | }, {
|
75 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
76 | loader: 'url',
|
77 | query: {
|
78 | limit: 1,
|
79 | name: 'img/[name].[hash:7].[ext]'
|
80 | }
|
81 | }, {
|
82 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
83 | loader: 'url',
|
84 | query: {
|
85 | limit: 1,
|
86 | name: 'fonts/[name].[hash:7].[ext]'
|
87 | }
|
88 | }]
|
89 | },
|
90 | babel: {
|
91 | presets: [["env", {
|
92 | "targets": ["last 5 versions"],
|
93 | "loose": true
|
94 | }], 'stage-0'],
|
95 | plugins: ['transform-vue-jsx', 'transform-runtime']
|
96 | },
|
97 | vue: {
|
98 | loaders: {
|
99 | css: _extractTextWebpackPlugin2.default.extract('vue-style-loader', 'css-loader')
|
100 | },
|
101 | postcss: [(0, _autoprefixer2.default)({ browsers: ['last 7 versions'] })]
|
102 | }
|
103 | };
|
104 |
|
105 | if (process.env[_config.serviceWorkerConfig.ENABLE_KEY]) {
|
106 | var ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
|
107 | config.plugins.push(new ServiceWorkerWebpackPlugin({
|
108 | entry: _path2.default.join(__dirname, 'sw.js'),
|
109 | excludes: _config.serviceWorkerConfig.excludes
|
110 | }));
|
111 | }
|
112 |
|
113 | module.exports = config; |
\ | No newline at end of file |