95 lines
2.3 KiB
JavaScript
95 lines
2.3 KiB
JavaScript
const path = require('path');
|
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const webpack = require('webpack');
|
|
|
|
// Where are your assets located in your project? This would typically be a path
|
|
// that contains folders such as: images, stylesheets and javascript.
|
|
var rootAssetPath = './assets';
|
|
|
|
var debug = true;
|
|
|
|
module.exports = {
|
|
"mode": debug ? "development":"production",
|
|
"entry": [
|
|
"./src/app.js",
|
|
"./src/app.scss"
|
|
],
|
|
"output": {
|
|
"path": path.join(__dirname, 'dist'),
|
|
"filename": "[name].js"
|
|
},
|
|
"devtool": "source-map",
|
|
/* "resolve": {
|
|
"alias":{
|
|
"jquery": "jquery/src/jquery"
|
|
}
|
|
},*/
|
|
"module": {
|
|
"rules": [
|
|
{
|
|
"test": /\.tsx?$/,
|
|
"exclude": /node_modules/,
|
|
"use": {
|
|
"loader": "ts-loader",
|
|
"options": {
|
|
"transpileOnly": true
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"test": /\.scss$/,
|
|
"use": [
|
|
MiniCssExtractPlugin.loader,
|
|
// "style-loader",
|
|
"css-loader",
|
|
"sass-loader"
|
|
]
|
|
},
|
|
{
|
|
"test": /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
"use": {
|
|
"loader": "url-loader?limit=10000&mimetype=application/font-woff",
|
|
"options": {
|
|
name: '[path][name].[ext]',
|
|
},
|
|
}
|
|
},
|
|
{
|
|
"test": /\.(ttf|eot|svg|gif)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
"use": [
|
|
"file-loader"
|
|
]
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
use: ['style-loader', 'css-loader'],
|
|
},
|
|
]
|
|
},
|
|
"optimization": {
|
|
minimize: !debug,
|
|
minimizer: [
|
|
new UglifyJsPlugin({
|
|
include: /\.js$/
|
|
}),
|
|
new OptimizeCSSAssetsPlugin({
|
|
include: /\.css$/
|
|
})
|
|
]
|
|
},
|
|
"plugins": [
|
|
new webpack.ProvidePlugin({
|
|
$: "jquery",
|
|
jQuery: "jquery"
|
|
}),
|
|
new MiniCssExtractPlugin("[name].css"),
|
|
],
|
|
devServer: {
|
|
contentBase: path.join(__dirname, 'dist'),
|
|
compress: true,
|
|
port: 8080
|
|
}
|
|
};
|