mon-entreprise/webpack/common.js

83 lines
1.2 KiB
JavaScript
Raw Normal View History

/* eslint-env node */
module.exports.styleLoader = styleLoader => ({
test: /\.css$/,
use: [
{ loader: styleLoader },
{
loader: 'css-loader',
options: {
sourceMap: true,
importLoaders: 1
}
},
{
loader: 'postcss-loader'
}
]
})
module.exports.commonLoaders = ({ legacy = false } = {}) => {
const babelLoader = {
loader: 'babel-loader',
options: {
cacheDirectory: true,
rootMode: 'upward',
presets: [
[
'@babel/preset-env',
{
targets: !legacy
? {
esmodules: true
}
: {
esmodules: false,
browsers: ['ie 11']
},
useBuiltIns: 'entry',
corejs: '3'
}
]
]
}
}
return [
{
test: /\.(js|ts|tsx)$/,
use: babelLoader,
exclude: /node_modules|dist/
},
{
test: /\.(jpe?g|png|svg)$/,
use: {
loader: 'file-loader',
options: {
name: 'images/[name].[ext]'
}
}
},
{
test: /\.yaml$/,
use: ['json-loader', 'yaml-loader']
},
{
test: /\.toml$/,
use: ['toml-loader']
},
{
test: /\.ne$/,
use: [babelLoader, 'nearley-loader']
},
{
test: /\.md$/,
use: ['raw-loader']
},
{
test: /\.ttf$/,
use: ['file-loader']
}
]
}