forked from wikimedia/mediawiki-extensions-Wikibase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
89 lines (84 loc) · 2.13 KB
/
vue.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
82
83
84
85
86
87
88
89
const { BannerPlugin } = require( 'webpack' );
const TerserPlugin = require( 'terser-webpack-plugin' );
const filePrefix = 'data-bridge.';
const DEV_MODE = process.env.WEBPACK_TARGET === 'dev';
/**
* In production libraries may be provided by ResourceLoader
* to allow their caching across applications,
* in dev it is still webpack's job to make them available
*/
function externals() {
if ( DEV_MODE ) {
return [];
}
// get external packages from @wmde/lib-version-check config
const package = require( './package.json' );
return Object.keys( package.config.remoteVersion );
}
module.exports = {
publicPath: '.',
productionSourceMap: false,
configureWebpack: () => ( {
output: {
filename: `${filePrefix}[name].js`,
libraryTarget: DEV_MODE ? undefined : 'commonjs2',
chunkFilename: 'vendor-chunks.js',
},
entry: {
app: './src/main.ts',
init: './src/mediawiki/data-bridge.init.ts',
},
externals: externals(),
optimization: {
splitChunks: {
minChunks: 2,
},
minimize: !DEV_MODE,
minimizer: [ new TerserPlugin( {
include: /\.js$/,
sourceMap: false,
extractComments: false,
} ) ],
},
plugins: [
// /*@nomin*/ instructs ResourceLoader not to try to minify our resources –
// especially important for the modern bundle (ES6 syntax not supported by RL).
new BannerPlugin( {
banner: '/*!/*@nomin*/', // /*! to avoid comment being removed later
raw: true, // must contain *exactly* that string, see ResourceLoader::FILTER_NOMIN
} ),
],
} ),
chainWebpack: ( config ) => {
if ( process.env.NODE_ENV === 'production' ) {
config.plugin( 'extract-css' )
.tap( ( [ options, ...args ] ) => [
Object.assign( {}, options, { filename: `css/${filePrefix}[name].css` } ),
...args,
] );
}
config.module
.rule( 'vue' )
.use( 'vue-loader' )
.tap( ( options ) => {
return {
...options,
compilerOptions: {
compatConfig: {
MODE: 3,
},
},
};
} );
},
css: {
loaderOptions: {
sass: {
additionalData: '@import "@/presentation/styles/_main.scss";',
},
},
},
transpileDependencies: [
'serialize-error',
],
};