UNPKG

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