1 | const path = require('path')
|
2 | var prod = process.env.NODE_ENV === 'production'
|
3 |
|
4 | module.exports = {
|
5 | wpyExt: '.wpy',
|
6 | eslint: true,
|
7 | cliLogs: !prod,
|
8 | build: {
|
9 | web: {
|
10 | htmlTemplate: path.join('src', 'index.template.html'),
|
11 | htmlOutput: path.join('web', 'index.html'),
|
12 | jsOutput: path.join('web', 'index.js')
|
13 | }
|
14 | },
|
15 | resolve: {
|
16 | alias: {
|
17 | '@': path.join(__dirname, 'src'),
|
18 | '@api': path.join(__dirname, 'src/api'),
|
19 | '@util': path.join(__dirname, 'src/utils'),
|
20 | '@wxs': path.join(__dirname, 'src/wxs'),
|
21 | '@com': path.join(__dirname, 'src/components')
|
22 | },
|
23 | aliasFields: ['wepy', 'weapp'],
|
24 | modules: ['node_modules']
|
25 | },
|
26 | compilers: {
|
27 | less: {
|
28 | compress: prod
|
29 | },
|
30 | |
31 |
|
32 |
|
33 | babel: {
|
34 | sourceMap: true,
|
35 | presets: [
|
36 | 'env'
|
37 | ],
|
38 | plugins: [
|
39 | 'transform-class-properties',
|
40 | 'transform-decorators-legacy',
|
41 | 'transform-object-rest-spread',
|
42 | 'transform-export-extensions'
|
43 | ]
|
44 | }
|
45 | },
|
46 | plugins: {
|
47 | },
|
48 | appConfig: {
|
49 | noPromiseAPI: ['createSelectorQuery']
|
50 | }
|
51 | }
|
52 |
|
53 | if (prod) {
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | module.exports.plugins = {
|
59 | uglifyjs: {
|
60 | filter: /\.js$/,
|
61 | config: {
|
62 | }
|
63 | },
|
64 | imagemin: {
|
65 | filter: /\.(jpg|png|jpeg)$/,
|
66 | config: {
|
67 | jpg: {
|
68 | quality: 80
|
69 | },
|
70 | png: {
|
71 | quality: 80
|
72 | }
|
73 | }
|
74 | }
|
75 | }
|
76 | }
|