加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
webpack.config.js 2.64 KB
一键复制 编辑 原始数据 按行查看 历史
chrisgarrity 提交于 2017-08-30 16:44 . Add Literacy and Math Curricula
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
// PostCss
const autoprefixer = require('autoprefixer');
const postcssVars = require('postcss-simple-vars');
const routes = require('./src/routes.json');
const TemplateConfig = require('./src/template-config.js');
// Prepare all entry points
const entry = {
// common: [
// // Vendor
// 'react',
// 'react-dom'
// ]
};
routes.forEach(route => {
if (!route.redirect) {
entry[route.name] = `./src/views/${route.name}/${route.name}.jsx`;
}
});
module.exports = {
entry: entry,
output: {
path: path.resolve(__dirname, 'build'),
filename: 'js/[name].bundle.js'
},
module: {
rules: [{
test: /\.jsx?$/,
loader: 'babel-loader',
include: path.resolve(__dirname, 'src'),
options: {
plugins: ['transform-object-rest-spread'],
presets: ['es2015', 'react']
}
},
{
test: /\.css$/,
use: [{
loader: 'style-loader'
}, {
loader: 'css-loader'
}, {
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: function () {
return [
postcssVars,
autoprefixer({
browsers: ['last 3 versions', 'Safari >= 8', 'iOS >= 8']
})
];
}
}
}]
},
{
test: /\.scss$/,
use: [{
loader: 'style-loader'
}, {
loader: 'css-loader'
}, {
loader: 'sass-loader'
}]
},
{
test: /\.(png|jpg|gif|eot|svg|ttf|woff)$/i,
loader: 'url-loader'
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.less$/,
use: [
'style-loader',
'css-loader',
'less-loader'
]
}
]
},
plugins: [
new CopyWebpackPlugin([{
from: 'static'
}])
].concat(routes
.filter(route => !route.redirect)
.map(route => new HtmlWebpackPlugin(Object.assign({}, TemplateConfig, {
title: route.title,
filename: `${route.name}.html`,
route: route
})))
)
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化