UNPKG

2.24 kBJavaScriptView Raw
1var path = require('path')
2var fs = require('fs')
3var utils = require('../libs/utils')
4var config = require('../config')
5var vueLoaderConfig = require('./vue-loader.conf')
6
7function resolve(dir) {
8 return path.join(config.paths.src, dir)
9}
10
11module.exports = {
12 target: require('mpvue-webpack-target'),
13 output: {
14 path: config.paths['wx-dist'],
15 filename: '[name].js',
16 publicPath: '/'
17 },
18 resolve: {
19 extensions: ['.js', '.vue', '.json', ".ts", ".tsx"],
20 alias: {
21 'vuex': 'vuex/dist/vuex.js',
22 'vue': 'mpvue',
23 //代表src
24 '@': resolve('./')
25 },
26 symlinks: false
27 },
28 module: {
29 rules: [{
30 test: /\.(tsx|ts)(\?.*)?$/,
31 loader: "ts-loader"
32 }, {
33 test: /\.vue$/,
34 loader: 'mpvue-loader',
35 options: vueLoaderConfig
36 }, {
37 test: /\.js$/,
38 include: [resolve('wx')],
39 use: [
40 'babel-loader', {
41 loader: 'mpvue-loader',
42 options: {
43 checkMPEntry: true
44 }
45 },
46 ]
47 }, {
48 test: /\.mustache$/,
49 loader: 'mustache-loader'
50 }, {
51 test: /\.ejs$/,
52 loader: 'marauder-ejs-loader'
53 }, {
54 test: /\.art$/,
55 loader: 'art-template-loader'
56 }, {
57 test: /\.(bmp|png|jpe?g|gif|svg)(\?.*)?$/,
58 loader: 'url-loader',
59 options: {
60 limit: 10000,
61 name: utils.assetsPath('img/[name].[hash:8].[ext]')
62 }
63 }, {
64 test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
65 loader: 'url-loader',
66 options: {
67 limit: 10000,
68 name: utils.assetsPath('media/[name]].[ext]')
69 }
70 }, {
71 test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
72 loader: 'file-loader',
73 options: {
74 limit: 10000,
75 name: utils.assetsPath('fonts/[name].[ext]')
76 }
77 }]
78 },
79 // Some libraries import Node modules but don't use them in the browser.
80 // Tell Webpack to provide empty mocks for them so importing them works.
81 node: {
82 // prevent webpack from injecting useless setImmediate polyfill because Vue
83 // source contains it (although only uses it if it's native).
84 setImmediate: false,
85 dgram: 'empty',
86 fs: 'empty',
87 net: 'empty',
88 tls: 'empty',
89 child_process: 'empty'
90 }
91}