Skip to content

Instantly share code, notes, and snippets.

@BTMPL
Created October 8, 2017 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BTMPL/3162cb5c527980e2f68bedd8a18da03f to your computer and use it in GitHub Desktop.
Save BTMPL/3162cb5c527980e2f68bedd8a18da03f to your computer and use it in GitHub Desktop.
var path = require("path");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
const ETP = new ExtractTextPlugin({
allChunks: true
});
module.exports = [
{
test: /\.js$/,
exclude: /node_modules/,
use: [{
loader: "babel-loader"
}]
},
{
test: /\.css$/,
use: [ { loader: 'style-loader' }, { loader: 'css-loader' } ]
},
{
test: /\.less$/,
use: ((env) => {
if(env == 'production') {
return ETP.extract({
use: [{
loader:'css-loader',
options: {
modules: true,
localIdentName: '[local]--[hash:base64:5]',
}
}, {
loader:'less-loader'
}]
});
}
else {
return [{
loader: 'style-loader'
}, {
loader:'css-loader',
options: {
modules: true,
localIdentName: '[local]--[hash:base64:5]',
}
}, {
loader:'less-loader'
}
];
}
})(process.env.NODE_ENV)
},
{
test: /\.(ttf|woff|jpeg|jpg|png|gif|svg|woff2|eot)$/,
use: [
{
loader: "file-loader",
options: {
outputPath: path.join("assets", "/"),
name: '[name]--[hash:base64:5].[ext]'
}
}
]
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment