forked from Rebolon/php-sf-flex-webpack-encore-vuejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
112 lines (96 loc) · 3.9 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
var Encore = require('@symfony/webpack-encore')
var OfflinePlugin = require('offline-plugin')
Encore
// the project directory where compiled assets will be stored
.setOutputPath('public/dist/')
// the public path used by the web server to access the previous directory
.setPublicPath('/dist')
.cleanupOutputBeforeBuild()
.enableSourceMaps(!Encore.isProduction())
// uncomment to create hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())
// first, install any presets you want to use (e.g. yarn add babel-preset-es2017)
// then, modify the default Babel configuration
// if you prefer using a .babelrc file then this configureBabel will be omit, reactPreset will also need to be loaded with babelrc file
// or you can use package.json <ith a node babel.presets like this :
/**
"babel": {
"presets": [
[
"env",
{
"targets": {
"browsers": [
"ie >= 9"
]
}
}
]
]
}
*/
.configureBabel(function(babelConfig) {
// add additional presets
babelConfig.presets.push('es2017')
babelConfig.presets.push('react')
// no plugins are added by default, but you can add some
// babelConfig.plugins.push('styled-jsx/babel');
})
// uncomment to define the assets of the project
// this one was used for this npm package: offline-plugin to manage cache (angular has already its own worker since ng-5.2 & cli-1.6)
.addEntry('service-worker', './assets/js/lib/service-worker.js')
.addEntry('js/vuejs', './assets/js/vuejs/app.js')
.addEntry('js/quasar', './assets/js/quasar/app.js')
.addEntry('js/login', './assets/js/login/app.js')
.addEntry('js/form', './assets/js/form/app.js')
.addEntry('js/api-platform-admin-react', './assets/js/api-platform-admin-react/index.js')
// for specific page css (not managed by vue file per example
.addStyleEntry('css/quasar-bootstrap', './assets/css/quasar-bootstrap.scss')
// this creates a 'vendor.js' file with common js code
// these modules will *not* be included in js/vuejs.js or js/quasar.js anymore
.createSharedEntry('vendor', [
'./assets/js/app.js',
// you can also extract CSS - this will create a 'vendor.css' file
// this CSS will *not* be included in vuejs.css anymore
'./assets/css/app.scss',
])
// uncomment if you use Sass/SCSS files
// parameters are not mandatory, only if webpack build is slow with bootstrap (http://symfony.com/doc/current/frontend/encore/bootstrap.html)
.enableSassLoader(function(sassOptions) {}, {
resolveUrlLoader: false,
})
// VueJS
.enableVueLoader()
// ReactJS
.enableReactPreset()
// uncomment for legacy applications that require $/jQuery as a global variable
// .autoProvidejQuery()
// customize webpack configuration
let config = Encore.getWebpackConfig();
// https://github.com/NekR/offline-plugin
config.plugins.push(new OfflinePlugin({
"strategy": "changed",
"responseStrategy": "cache-first",
"publicPath": "/dist/",
"caches": {
// offline plugin doesn't know about build folder
// if I added build in it , it will show something like : OfflinePlugin: Cache pattern [build/images/*] did not match any assets
"main": [
'*.json',
'*.css',
'*.js',
'img/*'
]
},
"ServiceWorker": {
"events": !Encore.isProduction(),
"entry": "./assets/js/lib/service-worker.js",
"cacheName": "SymfonyVue",
"navigateFallbackURL": '/',
"minify": !Encore.isProduction(),
"output": "./../service-worker.js",
"scope": "/"
},
"AppCache": null
}));
module.exports = config