Open weiting-tw opened 5 years ago
Webpack 4 requires the type
parameter when transforming JSON to JS:
module: {
rules: [
{
// Let's take our config file by absolute url
test: path.resolve(__dirname + 'package.json'),
use: {
loader: 'ng-package-constants-loader',
options: {
moduleName: 'app.constants' // name of the angular module
configKey: 'config.all', // object to pull from package.json
wrap: 'es6' // es6, true (default), false
}
},
type: 'javascript/auto'
}
]
}
When I upgrade webapck 4, and run build. I got this error message:
ERROR in ./config.json Module parse failed: Unexpected token a in JSON at position 0 while parsing near 'angular.module("app....' You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token a in JSON at position 0 while parsing near 'angular.module("app....'