150 lines
5.5 KiB
JavaScript
150 lines
5.5 KiB
JavaScript
const webpack = require('webpack');
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
module.exports = function webpackConfig (env) {
|
|
let devMode = (env !== 'production');
|
|
return {
|
|
devtool: devMode ? 'sourcemap' : false,
|
|
entry: {
|
|
vendor: [
|
|
'jquery', 'vue', 'bootstrap/dist/js/bootstrap', 'slick-carousel',
|
|
'moment', 'cookieconsent', 'picturefill', '@fancyapps/fancybox'
|
|
],
|
|
main: './Resources/Private/Assets/js/main.js',
|
|
boarderweek: './Resources/Private/Assets/js/boarderweek.js',
|
|
snowzone: './Resources/Private/Assets/js/snowzone.js',
|
|
unichamp: './Resources/Private/Assets/js/unichamp.js',
|
|
rte: './Resources/Private/Assets/css/rte.css'
|
|
},
|
|
output: {
|
|
path: __dirname + '/Resources/Public/js',
|
|
publicPath: '/typo3conf/ext/ep_theme/Resources/Public/',
|
|
filename: '[name].min.js'
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
jquery: __dirname + '/node_modules/jquery/src/jquery',
|
|
vue: devMode ? 'vue/dist/vue' : 'vue/dist/vue.min'
|
|
}
|
|
},
|
|
externals: {
|
|
'google': 'google'
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.js$/,
|
|
use: [
|
|
{
|
|
loader: 'babel-loader',
|
|
options: {
|
|
presets: ['es2015']
|
|
}
|
|
}
|
|
],
|
|
},
|
|
{
|
|
test: /\.vue$/,
|
|
use: [ 'vue-loader' ]
|
|
},
|
|
{
|
|
test: /\.(s)?css$/,
|
|
use: ExtractTextPlugin.extract({
|
|
fallback: 'style-loader',
|
|
use: [
|
|
{ loader: 'css-loader', options: { sourceMap: true, importLoaders: 3 } },
|
|
{ loader: 'postcss-loader', options: { sourceMap: true } },
|
|
'resolve-url-loader',
|
|
{ loader: 'sass-loader', options: { sourceMap: true } }
|
|
]
|
|
})
|
|
},
|
|
{
|
|
test: /\.svg$/,
|
|
exclude: /fonts/,
|
|
use: [
|
|
{
|
|
loader: 'url-loader',
|
|
options: {
|
|
name: '[name].[ext]',
|
|
outputPath: '../images/',
|
|
publicPath: '/typo3conf/ext/ep_theme/Resources/Public/images/'
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /\.(woff|woff2|eot|ttf|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
exclude: /images/,
|
|
use: {
|
|
loader: 'file-loader',
|
|
options: {
|
|
name: '[name].[ext]',
|
|
outputPath: '../fonts/',
|
|
publicPath: '/typo3conf/ext/ep_theme/Resources/Public/fonts/'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
test: /\.(gif|png)$/,
|
|
use: [
|
|
{
|
|
loader: 'url-loader',
|
|
options: {
|
|
limit: 4096,
|
|
name: '[name].[ext]',
|
|
outputPath: '../images/',
|
|
publicPath: '/typo3conf/ext/ep_theme/Resources/Public/images/'
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /\.(jpg|ico)$/,
|
|
use: [
|
|
{
|
|
loader: 'file-loader',
|
|
options: {
|
|
name: '[name].[ext]',
|
|
outputPath: '../images/',
|
|
publicPath: '/typo3conf/ext/ep_theme/Resources/Public/images/'
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
name: 'vendor',
|
|
minChunks: Infinity
|
|
}),
|
|
new webpack.ProvidePlugin({
|
|
$: 'jquery',
|
|
jQuery: 'jquery'
|
|
}),
|
|
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
|
new ExtractTextPlugin({
|
|
filename: '../css/[name].min.css',
|
|
}),
|
|
new CopyWebpackPlugin(
|
|
[
|
|
{
|
|
context: __dirname + '/Resources/Private/Assets/images',
|
|
from: '**/*',
|
|
to: __dirname + '/Resources/Public/images',
|
|
}
|
|
]
|
|
),
|
|
new CleanWebpackPlugin([
|
|
'Resources/Public/css',
|
|
'Resources/Public/images',
|
|
'Resources/Public/js',
|
|
'Resources/Public/fonts'
|
|
])
|
|
]
|
|
}
|
|
};
|