-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.neutrinorc.js
More file actions
135 lines (129 loc) · 3.77 KB
/
.neutrinorc.js
File metadata and controls
135 lines (129 loc) · 3.77 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
const react = require('@neutrinojs/react');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { StatsWriterPlugin } = require("webpack-stats-plugin");
const {DefinePlugin} = require("webpack");
const path = require('path');
const glob = require('glob');
//configure here the basepath for different development environments
//in production this variable is not used, as the basePath is always '/'
var ENV_BASE_PATH = '/php-react-skeleton/web/www';
module.exports = {
options: {
root: __dirname,
source: 'src',
output: 'www/bundles',
mains: glob.sync(__dirname + '/src/pages/**/index.js').reduce(function(obj, el){
let parentDirName = path.basename(path.dirname(el))
obj[parentDirName] = el;
return obj
},{}),
// mains: {
// index: {
// entry: 'pages/index.js'
// }
// }
},
use: [
react({
//https://neutrinojs.org/packages/web/#deployment-path
//this is the public path on the current work environment
//the value of this property is not set here, but in the
//middleware function at the bottom of this config
publicPath: '',
//we only want the bundles
html: false,
style: false,
font: {
name:
process.env.NODE_ENV === 'production'
? '[name].[hash:8].[ext]'
: '[name].[ext]',
},
image: {
limit: 4192,
name:
process.env.NODE_ENV === 'production'
? '[name].[hash:8].[ext]'
: '[name].[ext]',
},
clean: true,
devServer: {
port: 5000,
open: false,
//we want the bundles to be accessible to php
writeToDisk: true,
hot: true,
// liveReload: false,
// Redirect 404s to index.html, so that apps that use the HTML 5 History API work.
historyApiFallback: false,
overlay:{
warnings: true,
errors: true,
},
},
}),
(neutrino) => {
//add stats-plugin
neutrino.config
.plugin('stats')
.use(StatsWriterPlugin, [{
stats: {
all: false,
entrypoints: true,
}
}]);
//css loaders
neutrino.config.module
.rule('css')
.test(/\.css$/)
.use('style')
.loader('style-loader')
// .options({ injectType: 'linkTag' })
.end()
.use('css')
.loader('css-loader');
//avif image loader ( the default image-loader package does not support webp )
neutrino.config.module
.rule('avif')
.test(/\.avif$/)
.use('url')
.loader('url-loader')
.options({
limit: 4192,
name:
process.env.NODE_ENV === 'production'
? '[name].[hash:8].[ext]'
: '[name].[ext]',
});
//conditional configs
neutrino.config
.when(process.env.NODE_ENV === 'production',
//PRODUCTION
config => config
.output
.filename('[name].[contenthash:8].js')
.publicPath('/bundles/')
.end()
.plugin('injection')
.use(DefinePlugin, [{
__ENV_BASE_PATH__ : false
}]),
//DEVELOPMENT
config => config
.output
.filename('[name].js')
.publicPath(ENV_BASE_PATH + '/bundles/')
.end()
.plugin('clean')
.use(CleanWebpackPlugin)
.end()
.plugin('injection')
.use(DefinePlugin, [{
__ENV_BASE_PATH__ : JSON.stringify(ENV_BASE_PATH)
}])
.end()
.devtool('inline-source-map')
);
},
],
};