2016-10-24 16:14:03 +03:00
|
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
const plugins = {
|
|
|
|
'no-errors-plugin': new webpack.NoErrorsPlugin(),
|
|
|
|
'extract-text-plugin': new ExtractTextPlugin({
|
|
|
|
filename: '[name].css',
|
|
|
|
allChunks: true
|
|
|
|
}),
|
|
|
|
'loader-options-plugin': new webpack.LoaderOptionsPlugin({
|
|
|
|
options: {
|
|
|
|
postcss: {
|
2016-10-24 19:38:16 +03:00
|
|
|
plugins: [
|
2016-10-27 18:26:26 +03:00
|
|
|
require('postcss-import')(),
|
2016-10-25 19:22:19 +03:00
|
|
|
require('postcss-at-rules-variables')(),
|
2016-10-24 19:38:16 +03:00
|
|
|
require('postcss-modules-values'),
|
2016-10-27 18:06:40 +03:00
|
|
|
require('postcss-functions')({
|
|
|
|
functions: {
|
2016-10-27 18:47:03 +03:00
|
|
|
remCalc: function(values) {
|
|
|
|
values = values.replace('px', '');
|
|
|
|
values = values.split(' ');
|
|
|
|
let outputRems = '';
|
|
|
|
const base = 16;
|
|
|
|
values.forEach( (value, i) => {
|
|
|
|
const remValue = value / base;
|
|
|
|
outputRems += i === 0 ? `${remValue}rem` : ` ${remValue}rem`;
|
|
|
|
});
|
|
|
|
return outputRems;
|
2016-10-27 18:06:40 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}),
|
2016-10-24 23:58:09 +03:00
|
|
|
require('postcss-mixins')(),
|
2016-10-25 18:43:34 +03:00
|
|
|
require('postcss-for'),
|
2016-10-25 22:15:33 +03:00
|
|
|
require('postcss-cssnext')()
|
2016-10-24 19:38:16 +03:00
|
|
|
]
|
2016-10-24 16:14:03 +03:00
|
|
|
},
|
2016-10-26 16:03:23 +03:00
|
|
|
'embed-markdown-loader': {}
|
2016-10-24 16:14:03 +03:00
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.config = {
|
|
|
|
context: path.join(__dirname, '../'),
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, '../static'),
|
|
|
|
publicPath: '/static/',
|
|
|
|
filename: '[name].js'
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
plugins['no-errors-plugin'],
|
|
|
|
plugins['extract-text-plugin'],
|
|
|
|
plugins['loader-options-plugin']
|
|
|
|
],
|
|
|
|
resolveLoader: {
|
|
|
|
alias: {
|
|
|
|
'embed-markdown-loader': path.join(__dirname, './embed-markdown-loader')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
loaders: [{
|
|
|
|
test: /js?$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
include: [
|
|
|
|
path.join(__dirname, '../src'),
|
|
|
|
path.join(__dirname, '../docs')
|
|
|
|
],
|
|
|
|
loader: 'babel'
|
|
|
|
}, {
|
|
|
|
test: /\.json?$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
include: [
|
|
|
|
path.join(__dirname, '../src'),
|
|
|
|
path.join(__dirname, '../docs')
|
|
|
|
],
|
|
|
|
loader: 'json'
|
|
|
|
}, {
|
|
|
|
test: /\.md?$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
include: [
|
|
|
|
path.join(__dirname, '../src'),
|
|
|
|
path.join(__dirname, '../docs')
|
|
|
|
],
|
2016-10-24 16:37:12 +03:00
|
|
|
loader: 'raw-loader!embed-markdown-loader'
|
2016-10-24 16:14:03 +03:00
|
|
|
}, {
|
|
|
|
test: /\.css?$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
include: [
|
|
|
|
path.join(__dirname, '../src'),
|
|
|
|
path.join(__dirname, '../docs')
|
|
|
|
],
|
|
|
|
loader: ExtractTextPlugin.extract({
|
|
|
|
fallbackLoader: 'style-loader',
|
2016-10-26 12:51:06 +03:00
|
|
|
loader: [
|
|
|
|
'css-loader?',
|
|
|
|
'modules&importLoaders=1&',
|
|
|
|
'localIdentName=[name]__[local]___[hash:base64:5]!',
|
|
|
|
'postcss-loader'
|
|
|
|
].join('')
|
2016-10-24 16:14:03 +03:00
|
|
|
})
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.plugins = plugins;
|