Skip to content

Commit 5b00977

Browse files
committed
feat(webpack): improve comment stripping config
1 parent e44cb04 commit 5b00977

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

templates/app/webpack.make.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,24 @@ module.exports = function makeWebpackConfig(options) {
128128
sourceComments: false
129129
};<% } %>
130130

131+
<%_ if(filters.babel) { -%>
132+
config.babel = {
133+
shouldPrintComment(commentContents) {
134+
<%_ if(filters.flow) { -%>
135+
let regex = DEV
136+
// keep `// @flow`, `/*@ngInject*/`, & flow type comments in dev
137+
? /(@flow|@ngInject|^:)/
138+
// keep `/*@ngInject*/`
139+
: /@ngInject/;
140+
return regex.test(commentContents);
141+
<%_ } -%>
142+
<%_ if(!filters.flow) { -%>
143+
// keep `/*@ngInject*/`
144+
return /@ngInject/.test(commentContents);
145+
<%_ } -%>
146+
}
147+
}<% } %>
148+
131149
// Initialize module
132150
config.module = {
133151
preLoaders: [],
@@ -138,7 +156,6 @@ module.exports = function makeWebpackConfig(options) {
138156
// Compiles ES6 and ES7 into ES5 code
139157
test: /\.js$/,
140158
loader: 'babel',
141-
query: {comments: DEV || E2E},
142159
include: [
143160
path.resolve(__dirname, 'client/'),
144161
path.resolve(__dirname, 'node_modules/lodash-es/')

0 commit comments

Comments
 (0)