Created
March 25, 2017 18:56
-
-
Save MeirionHughes/9ca08845894aa74ded0bad770f3c773c to your computer and use it in GitHub Desktop.
aurelia webpack 2 + bootstrap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require("path"); | |
const { EnvironmentPlugin, ProvidePlugin, LoaderOptionsPlugin, optimize } = require("webpack"); | |
const { AureliaPlugin } = require("aurelia-webpack-plugin"); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const autoprefixer = require("autoprefixer"); | |
let config = { | |
entry: { "main": "aurelia-bootstrapper" }, // (1) | |
output: { // (2) | |
path: path.resolve(__dirname, "www"), | |
filename: "[name].js", | |
}, | |
devServer: { | |
contentBase: 'www' | |
}, | |
resolve: { // (3) | |
extensions: [".ts", ".js"], | |
modules: ["src", "node_modules"], | |
}, | |
module: { // (4) | |
rules: [ | |
{ | |
test: /\.scss$/i, use: ["style-loader", | |
"css-loader", | |
"postcss-loader", | |
{ | |
loader: "sass-loader", | |
options: { | |
includePaths: [ | |
path.resolve(__dirname, "node_modules/bootstrap/scss"), | |
path.resolve(__dirname, "node_modules/bootstrap/scss/mixins"), | |
path.resolve(__dirname, "node_modules/bootstrap/scss/utils")] | |
} | |
}] | |
}, | |
{ test: /\.html$/i, use: ["html-loader"] }, | |
{ test: /\.ts$/i, loaders: [/*'babel-loader?presets[]=es2015',*/ 'ts-loader'], exclude: path.resolve(__dirname, 'node_modules') }, | |
{ test: /\.json$/i, loader: 'json-loader', exclude: path.resolve(__dirname, 'node_modules') }, | |
{ test: /tether\.js$/, loader: "expose-loader?Tether" }, | |
{ test: /[\/\\]node_modules[\/\\]bluebird[\/\\].+\.js$/, loader: 'expose-loader?Promise' }, | |
{ test: require.resolve('jquery'), loader: 'expose-loader?$!expose-loader?jQuery' }, | |
{ test: /\.(png|gif|jpg)$/, loader: 'url-loader', query: { limit: 8192 } }, | |
{ test: /\.woff2(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader', query: { limit: 10000, mimetype: 'application/font-woff2' } }, | |
{ test: /\.woff(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader', query: { limit: 10000, mimetype: 'application/font-woff' } }, | |
{ test: /\.(ttf|eot|svg|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file-loader' }, | |
] | |
}, | |
plugins: [ | |
new AureliaPlugin({ | |
dist: 'es2015', | |
features: { ie: false, svg: true, unparser: false, polyfills: "esnext" }, | |
}), | |
new LoaderOptionsPlugin( | |
{ | |
test: /\.scss$/, | |
minimize: false, | |
debug: false, | |
context: __dirname, | |
options: { | |
postcss: [autoprefixer({ browsers: ['last 2 versions'] })] | |
} | |
} | |
), | |
new ProvidePlugin({ | |
'Promise': 'bluebird', | |
'fetch': 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch', | |
'$': 'jquery', | |
'jQuery': 'jquery', | |
'window.jQuery': 'jquery', | |
'Tether': 'tether' | |
}), | |
new HtmlWebpackPlugin({ | |
title: 'Custom template', | |
template: 'src/index.ejs', | |
}), | |
] | |
}; | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment