File tree 3 files changed +12
-25
lines changed
3 files changed +12
-25
lines changed Original file line number Diff line number Diff line change @@ -133,17 +133,17 @@ module.exports = {
133
133
// pass options to sass-loader
134
134
// @/ is an alias to src/
135
135
// so this assumes you have a file named `src/variables.sass`
136
- // Note: this option is named as "data " in sass-loader v7
136
+ // Note: this option is named as "prependData " in sass-loader v8
137
137
sass: {
138
- prependData : ` @import "~@/variables.sass"`
138
+ additionalData : ` @import "~@/variables.sass"`
139
139
},
140
140
// by default the `sass` option will apply to both syntaxes
141
141
// because `scss` syntax is also processed by sass-loader underlyingly
142
- // but when configuring the `data ` option
142
+ // but when configuring the `prependData ` option
143
143
// `scss` syntax requires an semicolon at the end of a statement, while `sass` syntax requires none
144
144
// in that case, we can target the `scss` syntax separately using the `scss` option
145
145
scss: {
146
- prependData : ` @import "~@/variables.scss";`
146
+ additionalData : ` @import "~@/variables.scss";`
147
147
},
148
148
// pass Less.js Options to less-loader
149
149
less: {
Original file line number Diff line number Diff line change @@ -135,17 +135,17 @@ module.exports = {
135
135
// передача настроек в sass-loader
136
136
// @/ это псевдоним к каталогу src/ поэтому предполагается,
137
137
// что у вас в проекте есть файл `src/variables.scss`
138
- // Примечание: эта опция называется "data " в sass-loader v7
138
+ // Примечание: эта опция называется "prependData " в sass-loader v8
139
139
sass: {
140
- prependData : ` @import "~@/variables.sass"`
140
+ additionalData : ` @import "~@/variables.sass"`
141
141
},
142
142
// по умолчанию опция `sass` будет применяться к обоим синтаксисам
143
143
// потому что синтаксис `scss` по сути также обрабатывается sass-loader
144
- // но при настройке опции `data ` синтаксис `scss` требует точку с запятой
144
+ // но при настройке опции `prependData ` синтаксис `scss` требует точку с запятой
145
145
// в конце оператора, в то время как для `sass` точки с запятой не требуется
146
146
// в этом случае синтаксис `scss` можно настроить отдельно с помощью опции `scss`
147
147
scss: {
148
- prependData : ` @import "~@/variables.scss";`
148
+ additionalData : ` @import "~@/variables.scss";`
149
149
},
150
150
// передача настроек Less.js в less-loader
151
151
less: {
Original file line number Diff line number Diff line change @@ -126,29 +126,16 @@ module.exports = {
126
126
sass: {
127
127
// @/ 是 src/ 的别名
128
128
// 所以这里假设你有 `src/variables.sass` 这个文件
129
- // 注意:在 sass-loader v7 中,这个选项名是 "data "
130
- prependData : ` @import "~@/variables.sass"`
129
+ // 注意:在 sass-loader v8 中,这个选项名是 "prependData "
130
+ additionalData : ` @import "~@/variables.sass"`
131
131
},
132
132
// 默认情况下 `sass` 选项会同时对 `sass` 和 `scss` 语法同时生效
133
133
// 因为 `scss` 语法在内部也是由 sass-loader 处理的
134
- // 但是在配置 `data ` 选项的时候
134
+ // 但是在配置 `prependData ` 选项的时候
135
135
// `scss` 语法会要求语句结尾必须有分号,`sass` 则要求必须没有分号
136
136
// 在这种情况下,我们可以使用 `scss` 选项,对 `scss` 语法进行单独配置
137
137
scss: {
138
- // sass-loader v8语法
139
- // prependData: `@import "~@/variables.scss";`
140
- // sass-loader v9语法
141
- additionalData (content , loaderContext ) {
142
- const { resourcePath , rootContext } = loaderContext;
143
- const relativePath = path .relative (rootContext, resourcePath);
144
- if (
145
- relativePath .replace (/ \\ / g , " /" ) !== " src/styles/variables.scss"
146
- ) {
147
- return ' @import "~@/styles/variables.scss";' + content;
148
- }
149
- return content;
150
- },
151
-
138
+ additionalData: ` @import "~@/variables.scss";`
152
139
},
153
140
// 给 less-loader 传递 Less.js 相关选项
154
141
less: {
You can’t perform that action at this time.
0 commit comments