-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
81 lines (80 loc) · 1.97 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const { resolve } = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const MinaWebpackPlugin = require('./plugin/MinaWebpackPlugin');
const MinaRuntimePlugin = require('./plugin/MinaRuntimePlugin');
const webpack = require('webpack');
const debuggable = process.env.BUILD_TYPE !== 'release'
module.exports = {
context: resolve('src'),
entry: './app.js',
output: {
path: resolve('dist'),
filename: '[name].js',
globalObject: "wx"
},
optimization: {
runtimeChunk: {
name: 'runtime'
},
splitChunks: {
chunks: "all",
name: 'common',
minChunks:2,
minSize:0
}
},
module: {
rules: [
{
test:/\.js$/,
use:'babel-loader'
},
{
test: /\.(scss)$/,
include: /src/,
use: [
{
loader: 'file-loader',
options: {
useRelativePath: true,
name: '[path][name].wxss',
context: resolve('src'),
},
},
{
loader: 'sass-loader',
options: {
includePaths: [resolve('src', 'styles'), resolve('src')],
},
},
],
}
]
},
plugins: [
new MinaWebpackPlugin(
{
scriptExtensions: ['.js'],
assetExtensions: ['.scss'],
}
),
new MinaRuntimePlugin(),
new CleanWebpackPlugin({
cleanStaleWebpackAssets: false,
}),
new webpack.EnvironmentPlugin({
NODE_ENV:JSON.stringify(process.env.NODE_ENV) || 'develop',
BUILD_TYPE: JSON.stringify(process.env.BUILD_TYPE) || 'debug'
}),
new CopyWebpackPlugin([
{
from: '**/*',
to: './',
ignore: ['**/*.js', '**/*.scss'],
},
]),
],
mode: debuggable ? 'none':'production',
devtool: debuggable ? 'inline-source-map' : 'source-map',
}