Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createExtractTextLoader() {
if (ExtractTextPluginVersion.match(/^1\./)) {
// extract-text-webpack-plugin 1.x
return ExtractTextPlugin.extract('style-loader', 'css-loader');
}
// extract-text-webpack-plugin 2.x
return ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' });
}
module.exports = function(config) {
// Define the root path alias
let alias = config.resolve.alias;
alias["@"] = baseConfig.rootPath;
// Use your ESLint
/*let eslintLoader = config.module.rules[0];
eslintLoader.use[0].options.useEslintrc = true;*/
// Add the stylus loader second-to-last
// (last one must remain as the "file-loader")
let loaderList = config.module.rules[1].oneOf;
loaderList.splice(loaderList.length - 1, 0, {
test: /\.styl$/,
loader: ExtractTextPlugin.extract(
Object.assign(
{
fallback: {
loader: require.resolve('style-loader'),
options: {
hmr: false
}
},
use: [
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
minimize: true,
sourceMap: true
}
webpackConfig.module.rules.filter(rule => rule.loader && /css/.test(rule.loader)).forEach(rule => {
const first = rule.loader
const rest = rule.loader.slice(1)
rule.loader = ExtractTextPlugin.extract({
fallback: first,
use: rest.join('!')
})
delete rule.loader
})
function extract(options) {
if (webpackVersion.match(/^1/)) {
return ExtractTextPlugin.extract(options.fallback, options.use)
}
else {
return ExtractTextPlugin.extract(options);
}
}
function extract(options) {
if (webpackVersion.match(/^1/)) {
return ExtractTextPlugin.extract(options.fallback, options.use)
}
else {
return ExtractTextPlugin.extract(options);
}
}
options: Object.assign({}, {sourceMap: shouldUseSourceMap}, options)
});
}
if (isDev) {
return {
test,
exclude,
use: loaders
};
}
return {
test,
exclude,
loader: ExtractTextPlugin.extract(
Object.assign(
{
fallback: require.resolve("style-loader"),
use: loaders
},
extractTextPluginOptions
)
)
};
};
function getProdStylesConfig() {
return {
plugins: [
new extract('css/[hash].css')
],
module: {
rules: [
{ test: /\.css$/, use: extract.extract({ fallback: 'style-loader', use: 'css-loader' }), include: [root('src/app/styles')] },
{ test: /\.css$/, use: ['to-string-loader', 'css-loader'], exclude: [root('src/app/styles')] },
{ test: /\.scss$|\.sass$/, loader: extract.extract({ fallback: 'style-loader', use: ['css-loader', 'sass-loader'] }), exclude: [root('src/app/components'), root('node_modules')] },
{ test: /\.scss$|\.sass$/, use: ['to-string-loader', 'css-loader', 'sass-loader'], exclude: [root('src/app/styles')] }
]
}
};
}
function getProdStylesConfig() {
return {
plugins: [
new extract('css/[name].css')
],
module: {
rules: [
{ test: /\.css$/, use: extract.extract({ fallback: 'style-loader', use: 'css-loader' }), include: [root('src/styles')] },
{ test: /\.css$/, use: ['to-string-loader', 'css-loader'], exclude: [root('src/styles')] },
{ test: /\.scss$|\.sass$/, loader: extract.extract({ fallback: 'style-loader', use: ['css-loader', 'sass-loader'] }), exclude: [root('src/app')] },
{ test: /\.scss$|\.sass$/, use: ['to-string-loader', 'css-loader', 'sass-loader'], exclude: [root('src/styles')] },
]
}
};
}
function getProdStylesConfig() {
return {
plugins: [
new extract('css/[name].css')
],
module: {
rules: [
{ test: /\.css$/, use: extract.extract({ fallback: 'style-loader', use: 'css-loader' }), include: [root('src/styles')] },
{ test: /\.css$/, use: ['to-string-loader', 'css-loader'], exclude: [root('src/styles')] },
{ test: /\.scss$|\.sass$/, loader: extract.extract({ fallback: 'style-loader', use: ['css-loader', 'sass-loader'] }), exclude: [root('src/app')] },
{ test: /\.scss$|\.sass$/, use: ['to-string-loader', 'css-loader', 'sass-loader'], exclude: [root('src/styles')] },
]
}
};
}
function getProdStylesConfig() {
return {
plugins: [
new extract('css/[name].css')
],
module: {
rules: [
{ test: /\.css$/, use: extract.extract({ fallback: 'style-loader', use: 'css-loader' }), include: [root('src/app/styles')] },
{ test: /\.css$/, use: ['to-string-loader', 'css-loader'], exclude: [root('src/app/styles')] },
{ test: /\.scss$|\.sass$/, loader: extract.extract({ fallback: 'style-loader', use: ['css-loader', 'sass-loader'] }), exclude: [root('src/app/components')] },
{ test: /\.scss$|\.sass$/, use: ['to-string-loader', 'css-loader', 'sass-loader'], exclude: [root('src/app/styles')] },
]
}
};
}