1 | const pathConfig = require('config').get('path')
|
2 | const webpackConf = require('config').get('webpack')
|
3 |
|
4 | const path = require('path')
|
5 | const webpack = require('webpack')
|
6 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
|
7 | const { VueLoaderPlugin } = require('vue-loader')
|
8 | const VueSSRClientPlugin = require('vue-server-renderer/client-plugin')
|
9 |
|
10 | const { alias } = require('./../alias')
|
11 | const { publicPath } = require('./../output.js')
|
12 | const { clientEntry } = require('./../entry.js')
|
13 | const { entries: assetsEntry = {} } = webpackConf
|
14 |
|
15 | module.exports = {
|
16 | target: 'web',
|
17 | mode: 'development',
|
18 | entry: Object.assign(
|
19 | {},
|
20 | assetsEntry,
|
21 | { global: pathConfig.global },
|
22 | clientEntry
|
23 | ),
|
24 | output: {
|
25 | filename: 'js/[name].js',
|
26 | path: pathConfig.dist,
|
27 | publicPath: publicPath
|
28 | },
|
29 | resolve: {
|
30 | alias,
|
31 | extensions: ['.js', '.json', '.vue']
|
32 | },
|
33 | module: {
|
34 | rules: [
|
35 | {
|
36 | test: /\.(png|jpe?g|gif|svg|woff2?|eot|ttf|otf)(\?.*)?$/,
|
37 | use: [
|
38 | {
|
39 | loader: 'url-loader',
|
40 | options: {
|
41 | limit: 10000,
|
42 | name: 'image/[name].[hash].[ext]'
|
43 | }
|
44 | }
|
45 | ]
|
46 | },
|
47 | {
|
48 | test: /\.js$/,
|
49 |
|
50 | use: [
|
51 | {
|
52 | loader: 'babel-loader',
|
53 | options: {
|
54 | presets: [
|
55 | [
|
56 | '@babel/preset-env',
|
57 | {
|
58 | targets: {
|
59 | browsers: ['Android >= 4.0', 'ios >= 6']
|
60 | },
|
61 | debug: true,
|
62 | include: [],
|
63 | useBuiltIns: false
|
64 | }
|
65 | ]
|
66 | ],
|
67 | plugins: ['@babel/plugin-syntax-dynamic-import']
|
68 | }
|
69 | }
|
70 | ]
|
71 | },
|
72 | {
|
73 | test: /\.vue$/,
|
74 | use: [
|
75 | {
|
76 | loader: 'vue-loader',
|
77 | options: {
|
78 | loaders: {
|
79 | css: ['vue-style-loader', 'css-loader'],
|
80 | scss: ['vue-style-loader', 'css-loader', 'sass-loader'],
|
81 | sass: ['vue-style-loader', 'css-loader', 'sass-loader'],
|
82 | js: {
|
83 | loader: 'babel-loader',
|
84 |
|
85 | options: {
|
86 | presets: [
|
87 | [
|
88 | '@babel/preset-env',
|
89 | {
|
90 | targets: {
|
91 | browsers: ['Android >= 4.0', 'ios >= 6']
|
92 | },
|
93 | debug: true,
|
94 | include: [],
|
95 | useBuiltIns: false
|
96 | }
|
97 | ]
|
98 | ],
|
99 | plugins: ['@babel/plugin-syntax-dynamic-import']
|
100 | }
|
101 | }
|
102 | }
|
103 | }
|
104 | }
|
105 | ]
|
106 | },
|
107 | {
|
108 | test: /\.css$/,
|
109 | use: ['vue-style-loader', 'css-loader']
|
110 | },
|
111 | {
|
112 | test: /\.scss$/,
|
113 | use: ['vue-style-loader', 'css-loader', 'sass-loader']
|
114 | },
|
115 | {
|
116 | test: /\.sass$/,
|
117 | use: ['vue-style-loader', 'css-loader', 'sass-loader']
|
118 | }
|
119 | ]
|
120 | },
|
121 | performance: {
|
122 | maxEntrypointSize: 300000,
|
123 | hints: false
|
124 | },
|
125 | plugins: [
|
126 | new VueLoaderPlugin(),
|
127 | new FriendlyErrorsPlugin(),
|
128 | new webpack.EnvironmentPlugin(['NODE_ENV']),
|
129 | new webpack.DefinePlugin({
|
130 | 'process.env.VUE_ENV': '"client"'
|
131 | }),
|
132 | new webpack.DllReferencePlugin({
|
133 | manifest: require(`${pathConfig.dll}/vendor.json`)
|
134 | }),
|
135 | new webpack.HotModuleReplacementPlugin(),
|
136 | new webpack.NoEmitOnErrorsPlugin(),
|
137 | new webpack.NamedModulesPlugin(),
|
138 | new VueSSRClientPlugin()
|
139 | ]
|
140 | }
|