Я пытаюсь использовать вычисленные свойства в моем объекте стиля пользовательского интерфейса Материал, но получаю неожиданную ошибку токена.
Ниже приведен фрагмент кода, ошибка и конфигурация babel-webpack.
const useStyles = makeStyles(theme => {
root: {
[desktop]: {
width: "80%",
}
}
});
//webpack.config.babel.js
...
const config = {
entry: ['@babel/polyfill', './src/components/index.js'],
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
devServer: {
host: '0.0.0.0',
historyApiFallback: {
index: 'index.dev.html',
},
},
output: {
path: path.resolve(__dirname, 'build'),
filename: 'main.js',
chunkFilename: '[name].js',
publicPath: '/build/',
},
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true,
extractComments: true,
}),
new OptimizeCSSAssetsPlugin({}),
],
splitChunks: {
cacheGroups: {
default: false,
vendors: {
// name of the chunk
name: 'vendor',
// sync + async chunks
chunks: 'all',
// import file path containing node_modules
test: /node_modules/,
priority: 20,
},
styles: {
name: 'styles',
test: /\.css$/,
chunks: "all",
enforce: true,
},
common: {
name: 'common',
minChunks: 2,
chunks: 'all',
priority: 10,
reuseExistingChunk: true,
enforce: true,
},
},
},
},
module: {
rules: [
{
test: /\.(js|ts)x?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: [
'@babel/typescript',
"@babel/preset-env",
'@babel/preset-react',
'@babel/preset-flow',
],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-object-rest-spread',
['@babel/plugin-proposal-decorators', {legacy: true}],
['@babel/plugin-proposal-class-properties', {loose: true}],
['@babel/plugin-transform-computed-properties', {loose: true}],
],
},
},
{
test: /\.s?[ac]ss$/,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
],
},
node: {
fs: 'empty',
},
// First array is dev only, second is production
plugins: devMode
? [
] : [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
new MiniCssExtractPlugin({
filename: '[name].css'
}),
],
};
// Exports
module.exports = config;
в Object.raise (/ node_modules / @ babel / parser / lib /index.js: 6931: 17)
в Object.unexpected (/node_modules/@babel/parser/lib/index.js:8324:16)
в Object.semicolon (/ node_modules / @ babel / parser /)lib / index.js: 8306: 40)
в Object.parseExpressionStatement (/node_modules/@babel/parser/lib/index.js:11147:10)
в Object.parseExpressionStatement (/ node_modules / @ babel /parser / lib / index.js: 2072: 18)
в Object.parseStatementContent (/node_modules/@babel/parser/lib/index.js:10746:19)
в Object.parseStatement (/ node_modules / @babel / parser / lib / index.js: 10612: 17)
в Object.parseStatement (/node_modules/@babel/parser/lib/index.js:2045:26)
в Object.parseBlockOrModuleBlockBody (/ node_modules/@babel/parser/lib/index.js:11188:25)
в Object.parseBlockBody (/node_modules/@babel/parser/lib/index.js:11175:10)
в Object.parseBlock (/ node_modules / @ столпотворение / Парсer / lib / index.js: 11159: 10)
в Object.parseStatementContent (/node_modules/@babel/parser/lib/index.js:10688:21)
в Object.parseStatement (/ node_modules / @babel / parser / lib / index.js: 10612: 17)
в Object.parseStatement (/node_modules/@babel/parser/lib/index.js:2045:26)
в Object.parseLabeledStatement (/ node_modules/@babel/parser/lib/index.js:11139:22)
at Object.parseStatementContent (/node_modules/@babel/parser/lib/index.js:10744:19)