1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/hkgit-angular1_webpack2

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
webpack.prod.config.js 3.7 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
kaikai Отправлено 17.10.2017 14:16 97daaaa
const path = require('path');
const webpack = require('webpack');
const htmlWebpackPlugin = require('html-webpack-plugin');
const autoprefixer = require('autoprefixer');
const extractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
// devtool: 'source-map',
entry: {
app: path.resolve(__dirname, 'app/app.main.js'),
vendor: ['angular', 'angular-animate', 'angular-toastr', 'angular-ui-bootstrap', 'angular-ui-grid', 'angular-ui-router', 'bootstrap', 'echarts', 'jquery', 'oi.select']
},
output: {
path: path.resolve(__dirname, 'build'),
// publicPath: 'app',
filename: 'js/[name].[hash:8].js',
chunkFilename: "chunks/[name].chunk.[chunkhash].js"
},
resolve: {
extensions: ['.js', '.ts', '.json', '.html', '.less', '.css'],
modules: [path.resolve(__dirname, "app"), "node_modules"],
alias: {
jquery: "jquery/dist/jquery.min"
}
},
module: {
rules: [{
test: /\.html$/,
use: ['raw-loader'],
exclude: /node_modules/
}, {
test: /\.js(x)*$/,
use: ['babel-loader'],
exclude: /node_modules/
}, {
test: /\.less$/,
use: extractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'less-loader', 'postcss-loader']
}),
include: path.resolve(__dirname, 'app')
}, {
test: /\.css$/,
use: extractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'postcss-loader']
})
}, {
test: /\.(jpg|png|gif|ico)$/,
use: ['url-loader?limit:10240&name=img/[name].[ext]']
}, {
test: /\.(woff|woff2|eot|ttf|svg)$/,
use: ['url-loader?limit:10240&name=fonts/[name].[ext]']
}]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.HashedModuleIdsPlugin(),
new webpack.LoaderOptionsPlugin({
options: {
postcss: function() {
return [autoprefixer({ browsers: ['last 2 versions'] })]
}
}
}),
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest'],
minChunks: function(module) {
return module.context && module.context.indexOf('node_modules') !== -1;
}
}),
new htmlWebpackPlugin({
template: path.resolve(__dirname, 'app/index.html'),
favicon: path.resolve(__dirname, 'app/img/favicon.ico')
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
new extractTextPlugin({
filename: 'css/[name].[hash:8].css',
disable: false,
allChunks: true
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
beautify: false, // 最紧凑的输出
comments: false, // 删除所有的注释
compress: {
warnings: false, // UglifyJs删除没有用到的代码时,不输出警告
drop_console: true, // 删除所有的'console'语句。可以兼容ie浏览器
collapse_vars: true, // 内嵌定义了但是只用到一次的变量
reduce_vars: true, // 提取出现多次但是没有定义成变量去引用的静态值
screw_ie8: true
},
mangle: {
screw_ie8: true,
keep_fnames: true
}
})
]
};

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/hkgit-angular1_webpack2.git
git@api.gitlife.ru:oschina-mirror/hkgit-angular1_webpack2.git
oschina-mirror
hkgit-angular1_webpack2
hkgit-angular1_webpack2
master