模块解析失败:意外的令牌(7:5)您可能需要适当的加载器来处理此文件类型。 :Webpack,Bootstrap

时间:2017-10-30 12:08:47

标签: javascript twitter-bootstrap webpack aurelia

在Aurelia应用中运行String searchUserXpath ="...."; String optionXpath ="----" driver.findElement(By.xpath(searchUserXpath )).sendKeys(entersearchOptionValue totally /partially ); //for example option value is HYderabad ,you HYd Then takes xpath of // HyderabaOPtion... driver.findElement(By.xpath(optionXpath )).click(); 时出现错误。

webpack --config webpack.config.vendor.js

我正在使用Webpack 3.8.1

Webpack.config.js

ERROR in ./node_modules/bootstrap/dist/css/bootstrap.css
Module parse failed: Unexpected token (7:5)
You may need an appropriate loader to handle this file type.

webpack.config.js

    //var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
var path = require('path');
var webpack = require('webpack');
const { AureliaPlugin } = require('aurelia-webpack-plugin');
var extractStyles = new (require('extract-text-webpack-plugin'))('mystyles.css');

var bundleOutputDir = './wwwroot/dist';
module.exports = (env) => {

    return [{
        stats: { modules: false },
        entry: { 'app': 'aurelia-bootstrapper' },
        resolve: {
            extensions: ['.ts', '.js'],
            modules: ['ClientApp', 'node_modules'],
        },
        output: {
            path: path.resolve(bundleOutputDir),
            publicPath: '/dist',
            filename: '[name].js'
        },
        module: {
            rules: [
                { test: /\.ts$/, include: /ClientApp/, loader: 'ts-loader', query: { silent: true } },
                { test: /\.html$/, loader: 'html-loader' },
                { test: /\.scss$/, loader: extractStyles.extract('css-loader!sass-loader') },
                { test: /\.css$/,  loader: 'style-loader!css-loader' },
                { test: /\.(png|gif|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' },
                { test: /\.json$/, loader: 'json-loader' }
            ]
        },
        plugins: [
            extractStyles,

            new webpack.DefinePlugin({ IS_DEV_BUILD: JSON.stringify(isDevBuild) }),
            new webpack.DllReferencePlugin({
                context: __dirname,
                manifest: require('./wwwroot/dist/vendor-manifest.json')
            }),
            new AureliaPlugin({ aureliaApp: 'boot' })

        ].concat(isDevBuild ? [
            // Plugins that apply in development builds only 
            new webpack.SourceMapDevToolPlugin({
                filename: '[file].map', // Remove this line if you prefer inline source maps
                moduleFilenameTemplate: path.relative(bundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
            })
            // ,
            //   new BundleAnalyzerPlugin({
            //     analyzerMode: 'static'
            // })
        ] : [
                // Plugins that apply in production builds only
                new webpack.optimize.UglifyJsPlugin()
            ])
    }];
}

1 个答案:

答案 0 :(得分:0)

移动&#34;装载机中的条目&#34;切入&#34;规则&#34;如下修正了问题。我相信在Webpack 3中已经弃用了加载器

 rules: [
            { test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' },
            { test: /\.css(\?|$)/, loader: extractCSS.extract(['css-loader']) },
            {
                test: require.resolve('jquery'),
                use: [{
                    loader: 'expose-loader',
                    options: 'jQuery'
                }, {
                    loader: 'expose-loader',
                    options: '$'
                }]
            }]