blog-web/themes/yilia/webpack.config.js
结发受长生 79c6a7588e 样式优化
2018-06-11 15:04:40 +08:00

77 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const webpack = require("webpack")
const autoprefixer = require('autoprefixer')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CleanPlugin = require('clean-webpack-plugin')
// 模板压缩
// 详见https://github.com/kangax/html-minifier#options-quick-reference
const minifyHTML = {
collapseInlineTagWhitespace: true,
collapseWhitespace: true,
minifyJS:true
}
const mainCss = new ExtractTextPlugin("css/main.css")
const extraCss = new ExtractTextPlugin("css/extra.css")
module.exports = {
entry: {
main: "./source-src/js/main.js",
slider: "./source-src/js/slider.js",
mobile: ["babel-polyfill", "./source-src/js/mobile.js"]
},
output: {
path: __dirname+"/source",
filename: "js/[name].[chunkhash].js"
},
module: {
loaders: [{
test: /\.js$/,
loader: 'babel-loader?cacheDirectory',
exclude: /node_modules/
},{
test: /\.html$/,
loader: 'html'
},{
test: /\.(scss|sass)$/,
loader: mainCss.extract({fallback:"style-loader",use:["css-loader","postcss-loader","sass-loader?outputStyle=compact"]})
},{
test: /\.css$/,
loaders: extraCss.extract({fallback:"style-loader",use:["css-loader?minimize=true","postcss-loader"]})
},{
test: /\.(png|jpe?g|gif|ico)$/,
loader: "url-loader",
options: {
limit: 1000,
publicPath: "../",
name: "images/[name].[ext]"
}
},{
test: /\.(svg|eot|ttf|woff2?|otf)$/,
loader: "url-loader",
options: {
limit: 1000,
publicPath: "../",
name: "fonts/[name].[hash:6].[ext]"
}
}]
},
plugins: [
mainCss,
extraCss,
new HtmlWebpackPlugin({
inject: false,
cache: false,
minify: minifyHTML,
template: './source-src/script.ejs',
filename: '../layout/_partial/script.ejs'
}),
new CleanPlugin(['source/js/*.js'],{
verbose: true,
dry: false,
})
],
watch: true
}