Comments (3)
Hey :) Can you paste some more lines before and after the sass-vars-loader configuration?
from sass-vars-loader.
sure.
maybe best with the whole file
// webpack.config.js
"use strict"; // eslint-disable-line
const webpack = require("webpack");
const merge = require("webpack-merge");
const CleanPlugin = require("clean-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const StyleLintPlugin = require("stylelint-webpack-plugin");
const CopyGlobsPlugin = require("copy-globs-webpack-plugin");
const FriendlyErrorsWebpackPlugin = require("friendly-errors-webpack-plugin");
const desire = require("./util/desire");
const config = require("./config");
// const sassVars = require(`${__dirname}/../vars`);
const jsonImporter = require("node-sass-json-importer");
// console.log(sassVars);
// console.log(desire(`${__dirname}/../../vars`));
const assetsFilenames = config.enabled.cacheBusting
? config.cacheBusting
: "[name]";
let webpackConfig = {
context: config.paths.assets,
entry: config.entry,
devtool: config.enabled.sourceMaps ? "#source-map" : undefined,
output: {
path: config.paths.dist,
publicPath: config.publicPath,
filename: `scripts/${assetsFilenames}.js`,
},
stats: {
hash: false,
version: false,
timings: false,
children: false,
errors: false,
errorDetails: false,
warnings: false,
chunks: false,
modules: false,
reasons: false,
source: false,
publicPath: false,
},
module: {
rules: [
{
enforce: "pre",
test: /\.js$/,
include: config.paths.assets,
use: "eslint",
},
{
enforce: "pre",
test: /\.(js|s?[ca]ss)$/,
include: config.paths.assets,
loader: "import-glob",
},
{
test: /\.js$/,
exclude: [/node_modules(?![/|\\](bootstrap|foundation-sites))/],
use: [
{ loader: "cache" },
{ loader: "buble", options: { objectAssign: "Object.assign" } },
],
},
{
test: /\.css$/,
include: config.paths.assets,
use: ExtractTextPlugin.extract({
fallback: "style",
use: [
{ loader: "cache" },
{
loader: "css",
options: { sourceMap: config.enabled.sourceMaps },
},
{
loader: "postcss",
options: {
config: { path: __dirname, ctx: config },
sourceMap: config.enabled.sourceMaps,
},
},
],
}),
},
{
test: /\.scss$/,
include: config.paths.assets,
use: ExtractTextPlugin.extract({
fallback: "style",
use: [
{ loader: "cache" },
{
loader: "css",
options: { sourceMap: config.enabled.sourceMaps },
},
{
loader: "postcss",
options: {
config: { path: __dirname, ctx: config },
sourceMap: config.enabled.sourceMaps,
},
},
{
loader: "resolve-url",
options: { sourceMap: config.enabled.sourceMaps },
},
// {
// loader: "sass",
// options: {
// sourceMap: config.enabled.sourceMaps,
// sourceComments: true,
// importer: jsonImporter(),
// },
// },
{
loader: "@epegzz/sass-vars-loader", options: {
syntax: 'scss',
files: [path.resolve(__dirname, '../../vars.json')]
},
],
}),
},
{
test: /\.(ttf|otf|eot|woff2?|png|jpe?g|gif|svg|ico)$/,
include: config.paths.assets,
loader: "url",
options: {
limit: 4096,
name: `[path]${assetsFilenames}.[ext]`,
},
},
{
test: /\.(ttf|otf|eot|woff2?|png|jpe?g|gif|svg|ico)$/,
include: /node_modules/,
loader: "url",
options: {
limit: 4096,
outputPath: "vendor/",
name: `${config.cacheBusting}.[ext]`,
},
},
],
},
resolve: {
modules: [config.paths.assets, "node_modules"],
enforceExtension: false,
},
resolveLoader: {
moduleExtensions: ["-loader"],
},
externals: {
jquery: "jQuery",
},
plugins: [
new CleanPlugin([config.paths.dist], {
root: config.paths.root,
verbose: false,
}),
/**
* It would be nice to switch to copy-webpack-plugin, but
* unfortunately it doesn't provide a reliable way of
* tracking the before/after file names
*/
new CopyGlobsPlugin({
pattern: config.copy,
output: `[path]${assetsFilenames}.[ext]`,
manifest: config.manifest,
}),
new ExtractTextPlugin({
filename: `styles/${assetsFilenames}.css`,
allChunks: true,
disable: config.enabled.watcher,
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
Popper: "popper.js/dist/umd/popper.js",
}),
new webpack.LoaderOptionsPlugin({
minimize: config.enabled.optimize,
debug: config.enabled.watcher,
stats: { colors: true },
}),
new webpack.LoaderOptionsPlugin({
test: /\.s?css$/,
options: {
output: { path: config.paths.dist },
context: config.paths.assets,
},
}),
new webpack.LoaderOptionsPlugin({
test: /\.js$/,
options: {
eslint: { failOnWarning: false, failOnError: true },
},
}),
new StyleLintPlugin({
failOnError: !config.enabled.watcher,
syntax: "scss",
}),
new FriendlyErrorsWebpackPlugin(),
],
}; /** Let's only load dependencies as needed */
/* eslint-disable global-require */ if (config.enabled.optimize) {
webpackConfig = merge(webpackConfig, require("./webpack.config.optimize"));
}
if (config.env.production) {
webpackConfig.plugins.push(new webpack.NoEmitOnErrorsPlugin());
}
if (config.enabled.cacheBusting) {
const WebpackAssetsManifest = require("webpack-assets-manifest");
webpackConfig.plugins.push(
new WebpackAssetsManifest({
output: "assets.json",
space: 2,
writeToDisk: false,
assets: config.manifest,
replacer: require("./util/assetManifestsFormatter"),
})
);
}
if (config.enabled.watcher) {
webpackConfig.entry = require("./util/addHotMiddleware")(webpackConfig.entry);
webpackConfig = merge(webpackConfig, require("./webpack.config.watch"));
}
/**
* During installation via sage-installer (i.e. composer create-project) some
* presets may generate a preset specific config (webpack.config.preset.js) to
* override some of the default options set here. We use webpack-merge to merge
* them in. If you need to modify Sage's default webpack config, we recommend
* that you modify this file directly, instead of creating your own preset
* file, as there are limitations to using webpack-merge which can hinder your
* ability to change certain options.
*/
module.exports = merge.smartStrategy({
"module.loaders": "replace",
})(webpackConfig, desire(`${__dirname}/webpack.config.preset`));
from sass-vars-loader.
There you go ;)
from sass-vars-loader.
Related Issues (20)
- Respect file order HOT 1
- Variable not getting to scss with web pack 3.11 in angular 5 HOT 5
- Typescript support HOT 1
- Leading zero in string gets removed HOT 14
- Missing dependencies in 4.1.0 HOT 1
- Broken as of version 4.3.0 HOT 6
- Can I use this for stylus or less ? HOT 2
- Module build failed with Vue-CLI HOT 14
- Improve documentation
- HRM doesn't work for variable files in symlinks or packages HOT 3
- Missing additional loader? Any help? HOT 1
- Variables undefined when use sass-loader.options.data attribute HOT 19
- Assertion error on precommit hook HOT 3
- Color names in JSON keys are interpreted as color objects by SASS HOT 4
- Unable to pass version string to add inside css comment HOT 2
- Is it possible to load the JSON file using inline loaders? HOT 1
- Passing transformer function as option HOT 3
- SassError: Invalid CSS after "..., -apple-system": expected ":", was ", BlinkMacSystemFon" HOT 1
- Webpack 5 implimentation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sass-vars-loader.