[webpack] use babel to ensure legacy browser compatibility (#645)

This commit is contained in:
Spencer
2018-03-15 14:53:43 -07:00
committed by GitHub
parent f28bbfc349
commit 4be86b402b
5 changed files with 41 additions and 18 deletions

View File

@ -1,5 +1,5 @@
const DefinePlugin = require('webpack/lib/DefinePlugin')
const { ignoreLoader, rel } = require('./lib')
const webpack = require('webpack')
const { jsLoader, ignoreLoader, rel } = require('./lib')
module.exports = {
context: rel('src'),
@ -9,7 +9,8 @@ module.exports = {
path: rel('dist'),
},
module: {
loaders: [
rules: [
jsLoader(),
ignoreLoader([
'src/lib/connectors/jquery.js',
'src/lib/connectors/xhr.js',
@ -18,7 +19,7 @@ module.exports = {
],
},
plugins: [
new DefinePlugin({
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
}),
],

View File

@ -1,5 +1,5 @@
const DefinePlugin = require('webpack/lib/DefinePlugin')
const { ignoreLoader, rel } = require('./lib')
const webpack = require('webpack')
const { jsLoader, ignoreLoader, rel } = require('./lib')
module.exports = {
context: rel('src'),
@ -11,7 +11,8 @@ module.exports = {
libraryTarget: 'umd'
},
module: {
loaders: [
rules: [
jsLoader(),
ignoreLoader([
'src/lib/connectors/jquery.js',
'src/lib/connectors/angular.js'
@ -19,7 +20,7 @@ module.exports = {
],
},
plugins: [
new DefinePlugin({
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
}),
],

View File

@ -1,5 +1,5 @@
const DefinePlugin = require('webpack/lib/DefinePlugin')
const { ignoreLoader, rel } = require('./lib')
const webpack = require('webpack')
const { jsLoader, ignoreLoader, rel } = require('./lib')
module.exports = {
context: rel('src'),
@ -9,7 +9,8 @@ module.exports = {
path: rel('dist'),
},
module: {
loaders: [
rules: [
jsLoader(),
ignoreLoader([
'src/lib/connectors/angular.js',
'src/lib/connectors/xhr.js',
@ -18,7 +19,7 @@ module.exports = {
],
},
plugins: [
new DefinePlugin({
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
}),
],

View File

@ -12,9 +12,23 @@ function ignoreLoader(ignores) {
function jsLoader() {
return {
loader: 'babel-loader',
test: /\.js$/,
include: rel('src'),
loader: 'babel-loader',
options: {
babelrc: false,
presets: [
['@babel/preset-env', {
targets: {
browsers: [
'last 2 versions',
'> 5%',
'Safari 7', // for PhantomJS support
]
}
}]
]
}
}
}